util/{Const,Writable}Buffer: eliminate static method Null(), use nullptr cast instead
This commit is contained in:
parent
23dff4f209
commit
65059f2add
@ -66,12 +66,12 @@ mod_loadfile(DecoderClient *client, InputStream &is)
|
|||||||
|
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
LogWarning(modplug_domain, "file is empty");
|
LogWarning(modplug_domain, "file is empty");
|
||||||
return { nullptr, 0 };
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size > MODPLUG_FILE_LIMIT) {
|
if (size > MODPLUG_FILE_LIMIT) {
|
||||||
LogWarning(modplug_domain, "file too large");
|
LogWarning(modplug_domain, "file too large");
|
||||||
return { nullptr, 0 };
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.size = size;
|
buffer.size = size;
|
||||||
|
@ -72,7 +72,7 @@ public:
|
|||||||
|
|
||||||
AllocatedArray(AllocatedArray &&other)
|
AllocatedArray(AllocatedArray &&other)
|
||||||
:buffer(other.buffer) {
|
:buffer(other.buffer) {
|
||||||
other.buffer = Buffer::Null();
|
other.buffer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
~AllocatedArray() {
|
~AllocatedArray() {
|
||||||
|
@ -60,10 +60,6 @@ struct ConstBuffer<void> {
|
|||||||
constexpr ConstBuffer(pointer_type _data, size_type _size)
|
constexpr ConstBuffer(pointer_type _data, size_type _size)
|
||||||
:data(_data), size(_size) {}
|
:data(_data), size(_size) {}
|
||||||
|
|
||||||
constexpr static ConstBuffer Null() {
|
|
||||||
return ConstBuffer(nullptr, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr static ConstBuffer<void> FromVoid(ConstBuffer<void> other) {
|
constexpr static ConstBuffer<void> FromVoid(ConstBuffer<void> other) {
|
||||||
return other;
|
return other;
|
||||||
}
|
}
|
||||||
@ -120,10 +116,6 @@ struct ConstBuffer {
|
|||||||
constexpr ConstBuffer(const T (&_data)[_size])
|
constexpr ConstBuffer(const T (&_data)[_size])
|
||||||
:data(_data), size(_size) {}
|
:data(_data), size(_size) {}
|
||||||
|
|
||||||
constexpr static ConstBuffer Null() {
|
|
||||||
return ConstBuffer(nullptr, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cast a ConstBuffer<void> to a ConstBuffer<T>, rounding down
|
* Cast a ConstBuffer<void> to a ConstBuffer<T>, rounding down
|
||||||
* to the next multiple of T's size.
|
* to the next multiple of T's size.
|
||||||
|
@ -60,10 +60,6 @@ struct WritableBuffer<void> {
|
|||||||
constexpr WritableBuffer(pointer_type _data, size_type _size)
|
constexpr WritableBuffer(pointer_type _data, size_type _size)
|
||||||
:data(_data), size(_size) {}
|
:data(_data), size(_size) {}
|
||||||
|
|
||||||
constexpr static WritableBuffer Null() {
|
|
||||||
return { nullptr, 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr bool IsNull() const {
|
constexpr bool IsNull() const {
|
||||||
return data == nullptr;
|
return data == nullptr;
|
||||||
}
|
}
|
||||||
@ -114,10 +110,6 @@ struct WritableBuffer {
|
|||||||
constexpr WritableBuffer(T (&_data)[_size])
|
constexpr WritableBuffer(T (&_data)[_size])
|
||||||
:data(_data), size(_size) {}
|
:data(_data), size(_size) {}
|
||||||
|
|
||||||
constexpr static WritableBuffer Null() {
|
|
||||||
return { nullptr, 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cast a WritableBuffer<void> to a WritableBuffer<T>,
|
* Cast a WritableBuffer<void> to a WritableBuffer<T>,
|
||||||
* rounding down to the next multiple of T's size.
|
* rounding down to the next multiple of T's size.
|
||||||
|
Loading…
Reference in New Issue
Block a user