util/AllocatedArray: add method release()

This commit is contained in:
Max Kellermann 2021-06-28 12:55:01 +02:00 committed by Max Kellermann
parent 53ffcf455c
commit ad00926e1b

View File

@ -76,7 +76,7 @@ public:
:AllocatedArray(other.buffer) {}
AllocatedArray(AllocatedArray &&other) noexcept
:buffer(std::exchange(other.buffer, nullptr)) {}
:buffer(other.release()) {}
~AllocatedArray() noexcept {
delete[] buffer.data;
@ -259,6 +259,13 @@ public:
buffer.size = _size;
}
/**
* Give up ownership of the allocated buffer and return it.
*/
Buffer release() noexcept {
return std::exchange(buffer, nullptr);
}
};
#endif