From 974b4a6c4bceb50bbe5bf316e9e273b62eaeceac Mon Sep 17 00:00:00 2001 From: tsepez Date: Tue, 13 Dec 2016 12:48:13 -0800 Subject: Return unique_ptr<>s from fxcodec/ Review-Url: https://codereview.chromium.org/2572843002 --- core/fxcodec/codec/fx_codec_jpeg.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'core/fxcodec/codec/fx_codec_jpeg.cpp') diff --git a/core/fxcodec/codec/fx_codec_jpeg.cpp b/core/fxcodec/codec/fx_codec_jpeg.cpp index 873b52a81c..fdfdd4faeb 100644 --- a/core/fxcodec/codec/fx_codec_jpeg.cpp +++ b/core/fxcodec/codec/fx_codec_jpeg.cpp @@ -7,11 +7,13 @@ #include #include +#include #include "core/fxcodec/codec/codec_int.h" #include "core/fxcodec/fx_codec.h" #include "core/fxcrt/fx_safe_types.h" #include "core/fxge/fx_dib.h" +#include "third_party/base/ptr_util.h" extern "C" { #undef FAR @@ -313,21 +315,22 @@ uint32_t CCodec_JpegDecoder::GetSrcOffset() { return (uint32_t)(m_SrcSize - src.bytes_in_buffer); } -CCodec_ScanlineDecoder* CCodec_JpegModule::CreateDecoder(const uint8_t* src_buf, - uint32_t src_size, - int width, - int height, - int nComps, - bool ColorTransform) { +std::unique_ptr CCodec_JpegModule::CreateDecoder( + const uint8_t* src_buf, + uint32_t src_size, + int width, + int height, + int nComps, + bool ColorTransform) { if (!src_buf || src_size == 0) return nullptr; - std::unique_ptr pDecoder(new CCodec_JpegDecoder); + auto pDecoder = pdfium::MakeUnique(); if (!pDecoder->Create(src_buf, src_size, width, height, nComps, ColorTransform)) { return nullptr; } - return pDecoder.release(); + return std::move(pDecoder); } bool CCodec_JpegModule::LoadInfo(const uint8_t* src_buf, -- cgit v1.2.3