From 6e72b2ecdb95f000dede3c80e0c32496c0b27a18 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 26 Apr 2017 15:14:35 -0700 Subject: Remove more |new|s, part 2 Change-Id: I13b43ceafc6a35bcc1e366546a4a408ea01fe4ab Reviewed-on: https://pdfium-review.googlesource.com/4534 Reviewed-by: dsinclair Commit-Queue: Tom Sepez --- core/fxcrt/fx_bidi.cpp | 6 ++++-- core/fxcrt/fx_stream.cpp | 4 ++-- core/fxcrt/fxcrt_posix.cpp | 7 +++++-- core/fxcrt/fxcrt_windows.cpp | 7 +++++-- core/fxcrt/ifxcrt_fileaccess.h | 2 +- 5 files changed, 17 insertions(+), 9 deletions(-) (limited to 'core/fxcrt') diff --git a/core/fxcrt/fx_bidi.cpp b/core/fxcrt/fx_bidi.cpp index 49333f6a76..25544546d3 100644 --- a/core/fxcrt/fx_bidi.cpp +++ b/core/fxcrt/fx_bidi.cpp @@ -5,10 +5,12 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "core/fxcrt/fx_bidi.h" -#include "core/fxcrt/fx_ucd.h" #include +#include "core/fxcrt/fx_ucd.h" +#include "third_party/base/ptr_util.h" + CFX_BidiChar::CFX_BidiChar() : m_CurrentSegment({0, 0, NEUTRAL}), m_LastSegment({0, 0, NEUTRAL}) {} @@ -50,7 +52,7 @@ void CFX_BidiChar::StartNewSegment(CFX_BidiChar::Direction direction) { CFX_BidiString::CFX_BidiString(const CFX_WideString& str) : m_Str(str), - m_pBidiChar(new CFX_BidiChar), + m_pBidiChar(pdfium::MakeUnique()), m_eOverallDirection(CFX_BidiChar::LEFT) { for (const auto& c : m_Str) { if (m_pBidiChar->AppendChar(c)) diff --git a/core/fxcrt/fx_stream.cpp b/core/fxcrt/fx_stream.cpp index 2c451c67b8..32b6ca3495 100644 --- a/core/fxcrt/fx_stream.cpp +++ b/core/fxcrt/fx_stream.cpp @@ -52,7 +52,7 @@ class CFX_CRTFileStream final : public IFX_SeekableStream { CFX_RetainPtr IFX_SeekableStream::CreateFromFilename( const char* filename, uint32_t dwModes) { - std::unique_ptr pFA(IFXCRT_FileAccess::Create()); + std::unique_ptr pFA = IFXCRT_FileAccess::Create(); if (!pFA->Open(filename, dwModes)) return nullptr; return pdfium::MakeRetain(std::move(pFA)); @@ -62,7 +62,7 @@ CFX_RetainPtr IFX_SeekableStream::CreateFromFilename( CFX_RetainPtr IFX_SeekableStream::CreateFromFilename( const wchar_t* filename, uint32_t dwModes) { - std::unique_ptr pFA(IFXCRT_FileAccess::Create()); + std::unique_ptr pFA = IFXCRT_FileAccess::Create(); if (!pFA->Open(filename, dwModes)) return nullptr; return pdfium::MakeRetain(std::move(pFA)); diff --git a/core/fxcrt/fxcrt_posix.cpp b/core/fxcrt/fxcrt_posix.cpp index 562c70c23e..3afe2c32d5 100644 --- a/core/fxcrt/fxcrt_posix.cpp +++ b/core/fxcrt/fxcrt_posix.cpp @@ -6,15 +6,18 @@ #include "core/fxcrt/fxcrt_posix.h" +#include + #include "core/fxcrt/fx_basic.h" +#include "third_party/base/ptr_util.h" #if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || \ _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || \ _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ // static -IFXCRT_FileAccess* IFXCRT_FileAccess::Create() { - return new CFXCRT_FileAccess_Posix; +std::unique_ptr IFXCRT_FileAccess::Create() { + return pdfium::MakeUnique(); } void FXCRT_Posix_GetFileMode(uint32_t dwModes, diff --git a/core/fxcrt/fxcrt_windows.cpp b/core/fxcrt/fxcrt_windows.cpp index 638338706e..6230c74eb7 100644 --- a/core/fxcrt/fxcrt_windows.cpp +++ b/core/fxcrt/fxcrt_windows.cpp @@ -6,13 +6,16 @@ #include "core/fxcrt/fxcrt_windows.h" +#include + #include "core/fxcrt/fx_string.h" +#include "third_party/base/ptr_util.h" #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ // static -IFXCRT_FileAccess* IFXCRT_FileAccess::Create() { - return new CFXCRT_FileAccess_Win64; +std::unique_ptr IFXCRT_FileAccess::Create() { + return pdfium::MakeUnique(); } void FXCRT_Windows_GetFileMode(uint32_t dwMode, diff --git a/core/fxcrt/ifxcrt_fileaccess.h b/core/fxcrt/ifxcrt_fileaccess.h index 9528b3b377..340c2d1eeb 100644 --- a/core/fxcrt/ifxcrt_fileaccess.h +++ b/core/fxcrt/ifxcrt_fileaccess.h @@ -15,7 +15,7 @@ class IFXCRT_FileAccess { public: - static IFXCRT_FileAccess* Create(); + static std::unique_ptr Create(); virtual ~IFXCRT_FileAccess() {} virtual bool Open(const CFX_ByteStringC& fileName, uint32_t dwMode) = 0; -- cgit v1.2.3