1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Implement stealing the memory from POCO buffer.

So I don't have to allocate one if I don't have to.
This commit is contained in:
Sandu Liviu Catalin 2021-09-05 12:03:57 +03:00
parent 81893bf236
commit d787803fd8

View File

@ -259,6 +259,16 @@ public:
swap(_ownMem, other._ownMem); swap(_ownMem, other._ownMem);
} }
T* steal()
/// Releases ownership of the buffer. Whoever gets hold of the buffer must invoke delete [] on it.
{
T* ptr = _ptr;
_ptr = 0;
_capacity = _used = 0; // Retrieve this before calling this method
_ownMem = false; // Consult this before calling this method
return ptr;
}
bool operator == (const Buffer& other) const bool operator == (const Buffer& other) const
/// Compare operator. /// Compare operator.
{ {