From 0f2ef5e85bce0d64683e8071151711f21fa3e052 Mon Sep 17 00:00:00 2001 From: m-holger Date: Thu, 25 May 2023 14:10:47 +0100 Subject: Add new Buffer method copy and deprecate copy constructor / assignment operator Also fix accidental Buffer copy in Pl_LZWDecoder::addToTable. --- include/qpdf/Buffer.hh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/qpdf/Buffer.hh b/include/qpdf/Buffer.hh index 719a6bd5..c0669c6c 100644 --- a/include/qpdf/Buffer.hh +++ b/include/qpdf/Buffer.hh @@ -41,10 +41,10 @@ class Buffer QPDF_DLL Buffer(unsigned char* buf, size_t size); - QPDF_DLL - Buffer(Buffer const&); - QPDF_DLL - Buffer& operator=(Buffer const&); + [[deprecated("Move Buffer or use Buffer::copy instead")]] QPDF_DLL Buffer(Buffer const&); + [[deprecated("Move Buffer or use Buffer::copy instead")]] QPDF_DLL Buffer& + operator=(Buffer const&); + QPDF_DLL Buffer(Buffer&&) noexcept; QPDF_DLL @@ -56,6 +56,14 @@ class Buffer QPDF_DLL unsigned char* getBuffer(); + // Create a new copy of the Buffer. The new Buffer owns an independent copy of the data. + QPDF_DLL + Buffer copy() const; + + // Only used during CI testing. + // ABI: remove when removing copy constructor / assignment operator + static void setTestMode() noexcept; + private: class Members { -- cgit v1.2.3-54-g00ecf