util/{Const,Writable}Buffer: eliminate static method Null(), use nullptr cast instead

This commit is contained in:
Max Kellermann 2017-11-21 12:43:09 +01:00
parent 23dff4f209
commit 65059f2add
4 changed files with 3 additions and 19 deletions

View File

@ -66,12 +66,12 @@ mod_loadfile(DecoderClient *client, InputStream &is)
if (size == 0) {
LogWarning(modplug_domain, "file is empty");
return { nullptr, 0 };
return nullptr;
}
if (size > MODPLUG_FILE_LIMIT) {
LogWarning(modplug_domain, "file too large");
return { nullptr, 0 };
return nullptr;
}
buffer.size = size;

View File

@ -72,7 +72,7 @@ public:
AllocatedArray(AllocatedArray &&other)
:buffer(other.buffer) {
other.buffer = Buffer::Null();
other.buffer = nullptr;
}
~AllocatedArray() {

View File

@ -60,10 +60,6 @@ struct ConstBuffer<void> {
constexpr ConstBuffer(pointer_type _data, size_type _size)
:data(_data), size(_size) {}
constexpr static ConstBuffer Null() {
return ConstBuffer(nullptr, 0);
}
constexpr static ConstBuffer<void> FromVoid(ConstBuffer<void> other) {
return other;
}
@ -120,10 +116,6 @@ struct ConstBuffer {
constexpr ConstBuffer(const T (&_data)[_size])
:data(_data), size(_size) {}
constexpr static ConstBuffer Null() {
return ConstBuffer(nullptr, 0);
}
/**
* Cast a ConstBuffer<void> to a ConstBuffer<T>, rounding down
* to the next multiple of T's size.

View File

@ -60,10 +60,6 @@ struct WritableBuffer<void> {
constexpr WritableBuffer(pointer_type _data, size_type _size)
:data(_data), size(_size) {}
constexpr static WritableBuffer Null() {
return { nullptr, 0 };
}
constexpr bool IsNull() const {
return data == nullptr;
}
@ -114,10 +110,6 @@ struct WritableBuffer {
constexpr WritableBuffer(T (&_data)[_size])
:data(_data), size(_size) {}
constexpr static WritableBuffer Null() {
return { nullptr, 0 };
}
/**
* Cast a WritableBuffer<void> to a WritableBuffer<T>,
* rounding down to the next multiple of T's size.