From e6db16e7e6cdc3dd213c16de0d792b77656ac7a6 Mon Sep 17 00:00:00 2001 From: tsepez Date: Mon, 19 Sep 2016 10:45:09 -0700 Subject: Clean up CPDF_Stream. Replace the CPDF_Stream(nullptr, 0, nullptr) pattern with a default ctor. Remove unused parameters from CPDF_Stream::SetData(). Both are always passed as FALSE. CPDF_Stream declared its own m_GenNum, which shadowed the one in CPDF_Object. It was used only to distinguish file/memory streams, so add a bool explicitly for this purpose. Remove the union, it would be sad if we confused user data with a C++ object with virtual function calls. Use unique_ptrs with appropriate deleters to manage memory. Review-Url: https://codereview.chromium.org/2347993002 --- core/fpdfapi/fpdf_page/cpdf_image.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'core/fpdfapi/fpdf_page/cpdf_image.cpp') diff --git a/core/fpdfapi/fpdf_page/cpdf_image.cpp b/core/fpdfapi/fpdf_page/cpdf_image.cpp index 02e492b27d..32b69bf9cb 100644 --- a/core/fpdfapi/fpdf_page/cpdf_image.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_image.cpp @@ -116,7 +116,7 @@ CPDF_Dictionary* CPDF_Image::InitJPEG(uint8_t* pData, uint32_t size) { m_Width = width; m_Height = height; if (!m_pStream) - m_pStream = new CPDF_Stream(nullptr, 0, nullptr); + m_pStream = new CPDF_Stream; return pDict; } @@ -329,9 +329,9 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) { dest_offset = 0; } } - if (!m_pStream) { - m_pStream = new CPDF_Stream(nullptr, 0, nullptr); - } + if (!m_pStream) + m_pStream = new CPDF_Stream; + m_pStream->InitStream(dest_buf, dest_size, pDict); m_bIsMask = pBitmap->IsAlphaMask(); m_Width = BitmapWidth; -- cgit v1.2.3