X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1a6a6043f79b8b12958e6cb09d443213a969507d..b70462f4f790b87f51e34c279837efb75545be28:/include/wx/buffer.h diff --git a/include/wx/buffer.h b/include/wx/buffer.h index 7a550a9310..dac2adf1bd 100644 --- a/include/wx/buffer.h +++ b/include/wx/buffer.h @@ -148,9 +148,9 @@ public: ~wxMemoryBuffer() { free(m_data); } // Accessors - void* GetData() { return m_data; } - size_t GetBufSize() { return m_size; } - size_t GetDataLen() { return m_len; } + void* GetData() const { return m_data; } + size_t GetBufSize() const { return m_size; } + size_t GetDataLen() const { return m_len; } void SetBufSize(size_t size) { ResizeIfNeeded(size); } void SetDataLen(size_t len) @@ -179,7 +179,7 @@ public: // Other ways to append to the buffer void AppendByte(char data) { ResizeIfNeeded(m_len + 1); - *((char*)m_data) = data; + *(((char*)m_data)+m_len) = data; m_len += 1; } void AppendData(void* data, size_t len) @@ -190,6 +190,35 @@ public: operator const char *() const { return (const char*)m_data; } + + // Copy and assignment + wxMemoryBuffer(const wxMemoryBuffer& src) + { + m_data = src.m_data; + m_size = src.m_size; + m_len = src.m_len; + + // no reference count yet... + ((wxMemoryBuffer*)&src)->m_data = NULL; + ((wxMemoryBuffer*)&src)->m_size = 0; + ((wxMemoryBuffer*)&src)->m_len = 0; + } + + wxMemoryBuffer& operator=(const wxMemoryBuffer& src) + { + m_data = src.m_data; + m_size = src.m_size; + m_len = src.m_len; + + // no reference count yet... + ((wxMemoryBuffer*)&src)->m_data = NULL; + ((wxMemoryBuffer*)&src)->m_size = 0; + ((wxMemoryBuffer*)&src)->m_len = 0; + + return *this; + } + + protected: void ResizeIfNeeded(size_t newSize) @@ -202,8 +231,6 @@ protected: } } - DECLARE_NO_COPY_CLASS(wxMemoryBuffer) - private: void* m_data; size_t m_size;