From: Václav Slavík Date: Mon, 26 Apr 2010 20:51:07 +0000 (+0000) Subject: Add wxMemoryBuffer::release(). X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/8dffb6b1a7ddfbb22667d9544dbe11ca49ca046c?ds=sidebyside Add wxMemoryBuffer::release(). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64153 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/buffer.h b/include/wx/buffer.h index d9640e25c0..574d0df073 100644 --- a/include/wx/buffer.h +++ b/include/wx/buffer.h @@ -468,6 +468,21 @@ private: delete this; } + void *release() + { + if ( m_data == NULL ) + return NULL; + + wxASSERT_MSG( m_ref == 1, "can't release shared buffer" ); + + void *p = m_data; + m_data = NULL; + m_len = + m_size = 0; + + return p; + } + // the buffer containing the data void *m_data; @@ -570,6 +585,13 @@ public: operator const char *() const { return (const char*)GetData(); } + // gives up ownership of data, returns the pointer; after this call, + // data isn't freed by the buffer and its content is resent to empty + void *release() + { + return m_bufdata->release(); + } + private: wxMemoryBufferData* m_bufdata; };