From d787803fd82f0e0201fa4984cb6271199d8df2c2 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Sun, 5 Sep 2021 12:03:57 +0300 Subject: [PATCH] Implement stealing the memory from POCO buffer. So I don't have to allocate one if I don't have to. --- vendor/POCO/Foundation/include/Poco/Buffer.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vendor/POCO/Foundation/include/Poco/Buffer.h b/vendor/POCO/Foundation/include/Poco/Buffer.h index 87c59f16..69206778 100644 --- a/vendor/POCO/Foundation/include/Poco/Buffer.h +++ b/vendor/POCO/Foundation/include/Poco/Buffer.h @@ -259,6 +259,16 @@ public: 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 /// Compare operator. {