From 47fb8c06acd0ff9ea50c8c2d7f67510ea5c28577 Mon Sep 17 00:00:00 2001 From: tsepez Date: Thu, 15 Dec 2016 13:51:34 -0800 Subject: Return unique_ptr from CFX_BinaryBuf::DetachBuffer() In turn, make CPDF_Stream() take an unique_ptr. Review-Url: https://codereview.chromium.org/2584683002 --- core/fxcrt/fx_basic.h | 2 +- core/fxcrt/fx_basic_buffer.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'core/fxcrt') diff --git a/core/fxcrt/fx_basic.h b/core/fxcrt/fx_basic.h index e974e3061c..7096e6f8df 100644 --- a/core/fxcrt/fx_basic.h +++ b/core/fxcrt/fx_basic.h @@ -41,7 +41,7 @@ class CFX_BinaryBuf { void Delete(int start_index, int count); // Releases ownership of |m_pBuffer| and returns it. - uint8_t* DetachBuffer(); + std::unique_ptr DetachBuffer(); protected: void ExpandBuf(FX_STRSIZE size); diff --git a/core/fxcrt/fx_basic_buffer.cpp b/core/fxcrt/fx_basic_buffer.cpp index fcd156b079..14a85c2ee5 100644 --- a/core/fxcrt/fx_basic_buffer.cpp +++ b/core/fxcrt/fx_basic_buffer.cpp @@ -6,6 +6,8 @@ #include #include +#include +#include #include "core/fxcrt/fx_basic.h" #include "core/fxcrt/fx_safe_types.h" @@ -36,10 +38,10 @@ void CFX_BinaryBuf::Clear() { m_DataSize = 0; } -uint8_t* CFX_BinaryBuf::DetachBuffer() { +std::unique_ptr CFX_BinaryBuf::DetachBuffer() { m_DataSize = 0; m_AllocSize = 0; - return m_pBuffer.release(); + return std::move(m_pBuffer); } void CFX_BinaryBuf::EstimateSize(FX_STRSIZE size, FX_STRSIZE step) { -- cgit v1.2.3