Commit ad00926e authored by Max Kellermann's avatar Max Kellermann Committed by Max Kellermann

util/AllocatedArray: add method release()

parent 53ffcf45
...@@ -76,7 +76,7 @@ public: ...@@ -76,7 +76,7 @@ public:
:AllocatedArray(other.buffer) {} :AllocatedArray(other.buffer) {}
AllocatedArray(AllocatedArray &&other) noexcept AllocatedArray(AllocatedArray &&other) noexcept
:buffer(std::exchange(other.buffer, nullptr)) {} :buffer(other.release()) {}
~AllocatedArray() noexcept { ~AllocatedArray() noexcept {
delete[] buffer.data; delete[] buffer.data;
...@@ -259,6 +259,13 @@ public: ...@@ -259,6 +259,13 @@ public:
buffer.size = _size; buffer.size = _size;
} }
/**
* Give up ownership of the allocated buffer and return it.
*/
Buffer release() noexcept {
return std::exchange(buffer, nullptr);
}
}; };
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment