From e5cb0b191aed020da99757c117dae014ea65c6ba Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 26 Oct 2016 15:06:11 -0700 Subject: Take advantage of implicit std::unique_ptr<>(nulltpr_t) ctor. Review-Url: https://codereview.chromium.org/2453163002 --- core/fpdfapi/font/cpdf_font.cpp | 2 +- core/fpdfapi/page/cpdf_clippath.cpp | 2 +- core/fpdfapi/page/cpdf_colorspace.cpp | 14 +++++++------- core/fpdfapi/page/fpdf_page_func.cpp | 3 ++- core/fpdfapi/render/fpdf_render_pattern.cpp | 2 +- core/fpdfdoc/cpdf_annotlist.cpp | 4 ++-- fpdfsdk/fpdf_progressive.cpp | 2 +- fpdfsdk/fpdfdoc_unittest.cpp | 2 +- fpdfsdk/fpdfview.cpp | 6 +++--- fpdfsdk/pdfwindow/PWL_FontMap.cpp | 3 +-- xfa/fgas/crt/fgas_memory.cpp | 2 +- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp index d39f752a8b..c5da4ea519 100644 --- a/core/fpdfapi/font/cpdf_font.cpp +++ b/core/fpdfapi/font/cpdf_font.cpp @@ -343,7 +343,7 @@ std::unique_ptr CPDF_Font::Create(CPDF_Document* pDoc, pFont->m_pFontDict = pFontDict; pFont->m_pDocument = pDoc; pFont->m_BaseFont = pFontDict->GetStringFor("BaseFont"); - return pFont->Load() ? std::move(pFont) : std::unique_ptr(); + return pFont->Load() ? std::move(pFont) : nullptr; } uint32_t CPDF_Font::GetNextChar(const FX_CHAR* pString, diff --git a/core/fpdfapi/page/cpdf_clippath.cpp b/core/fpdfapi/page/cpdf_clippath.cpp index 8c268a1b5e..9d4b737d33 100644 --- a/core/fpdfapi/page/cpdf_clippath.cpp +++ b/core/fpdfapi/page/cpdf_clippath.cpp @@ -100,7 +100,7 @@ void CPDF_ClipPath::AppendTexts( if (pData->m_TextList.size() + pTexts->size() <= FPDF_CLIPPATH_MAX_TEXTS) { for (size_t i = 0; i < pTexts->size(); i++) pData->m_TextList.push_back(std::move((*pTexts)[i])); - pData->m_TextList.push_back(std::unique_ptr()); + pData->m_TextList.push_back(nullptr); } pTexts->clear(); } diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp index fe840d10df..e43bacc079 100644 --- a/core/fpdfapi/page/cpdf_colorspace.cpp +++ b/core/fpdfapi/page/cpdf_colorspace.cpp @@ -332,7 +332,7 @@ CPDF_ColorSpace* CPDF_ColorSpace::GetStockCS(int family) { std::unique_ptr CPDF_ColorSpace::Load(CPDF_Document* pDoc, CPDF_Object* pObj) { if (!pObj) - return std::unique_ptr(); + return nullptr; if (pObj->IsName()) { return std::unique_ptr( @@ -341,7 +341,7 @@ std::unique_ptr CPDF_ColorSpace::Load(CPDF_Document* pDoc, if (CPDF_Stream* pStream = pObj->AsStream()) { CPDF_Dictionary* pDict = pStream->GetDict(); if (!pDict) - return std::unique_ptr(); + return nullptr; for (const auto& it : *pDict) { std::unique_ptr pRet; @@ -351,16 +351,16 @@ std::unique_ptr CPDF_ColorSpace::Load(CPDF_Document* pDoc, if (pRet) return pRet; } - return std::unique_ptr(); + return nullptr; } CPDF_Array* pArray = pObj->AsArray(); if (!pArray || pArray->IsEmpty()) - return std::unique_ptr(); + return nullptr; CPDF_Object* pFamilyObj = pArray->GetDirectObjectAt(0); if (!pFamilyObj) - return std::unique_ptr(); + return nullptr; CFX_ByteString familyname = pFamilyObj->GetString(); if (pArray->GetCount() == 1) @@ -386,11 +386,11 @@ std::unique_ptr CPDF_ColorSpace::Load(CPDF_Document* pDoc, } else if (id == FXBSTR_ID('P', 'a', 't', 't')) { pCS.reset(new CPDF_PatternCS(pDoc)); } else { - return std::unique_ptr(); + return nullptr; } pCS->m_pArray = pArray; if (!pCS->v_Load(pDoc, pArray)) - return std::unique_ptr(); + return nullptr; return pCS; } diff --git a/core/fpdfapi/page/fpdf_page_func.cpp b/core/fpdfapi/page/fpdf_page_func.cpp index a2e31f94bb..df658844cd 100644 --- a/core/fpdfapi/page/fpdf_page_func.cpp +++ b/core/fpdfapi/page/fpdf_page_func.cpp @@ -751,7 +751,8 @@ std::unique_ptr CPDF_Function::Load(CPDF_Object* pFuncObj) { pFunc.reset(new CPDF_PSFunc()); if (!pFunc || !pFunc->Init(pFuncObj)) - return std::unique_ptr(); + return nullptr; + return pFunc; } diff --git a/core/fpdfapi/render/fpdf_render_pattern.cpp b/core/fpdfapi/render/fpdf_render_pattern.cpp index f55a0e8b97..5238550bf5 100644 --- a/core/fpdfapi/render/fpdf_render_pattern.cpp +++ b/core/fpdfapi/render/fpdf_render_pattern.cpp @@ -819,7 +819,7 @@ std::unique_ptr DrawPatternBitmap( std::unique_ptr pBitmap(new CFX_DIBitmap); if (!pBitmap->Create(width, height, pPattern->colored() ? FXDIB_Argb : FXDIB_8bppMask)) { - return std::unique_ptr(); + return nullptr; } CFX_FxgeDevice bitmap_device; bitmap_device.Attach(pBitmap.get(), false, nullptr, false); diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp index b626115de1..4821f8e6dd 100644 --- a/core/fpdfdoc/cpdf_annotlist.cpp +++ b/core/fpdfdoc/cpdf_annotlist.cpp @@ -25,13 +25,13 @@ std::unique_ptr CreatePopupAnnot(CPDF_Annot* pAnnot, CPDF_Document* pDocument) { CPDF_Dictionary* pParentDict = pAnnot->GetAnnotDict(); if (!pParentDict) - return std::unique_ptr(); + return nullptr; // TODO(jaepark): We shouldn't strip BOM for some strings and not for others. // See pdfium:593. CFX_WideString sContents = pParentDict->GetUnicodeTextFor("Contents"); if (sContents.IsEmpty()) - return std::unique_ptr(); + return nullptr; CPDF_Dictionary* pAnnotDict = new CPDF_Dictionary(pDocument->GetByteStringPool()); diff --git a/fpdfsdk/fpdf_progressive.cpp b/fpdfsdk/fpdf_progressive.cpp index 1933c88485..13349cd762 100644 --- a/fpdfsdk/fpdf_progressive.cpp +++ b/fpdfsdk/fpdf_progressive.cpp @@ -91,5 +91,5 @@ DLLEXPORT void STDCALL FPDF_RenderPage_Close(FPDF_PAGE page) { return; pContext->m_pDevice->RestoreState(false); - pPage->SetRenderContext(std::unique_ptr()); + pPage->SetRenderContext(nullptr); } diff --git a/fpdfsdk/fpdfdoc_unittest.cpp b/fpdfsdk/fpdfdoc_unittest.cpp index fc85404dba..48be72399c 100644 --- a/fpdfsdk/fpdfdoc_unittest.cpp +++ b/fpdfsdk/fpdfdoc_unittest.cpp @@ -25,7 +25,7 @@ class CPDF_TestDocument : public CPDF_Document { public: - CPDF_TestDocument() : CPDF_Document(std::unique_ptr()) {} + CPDF_TestDocument() : CPDF_Document(nullptr) {} void SetRoot(CPDF_Dictionary* root) { m_pRootDict = root; } CPDF_IndirectObjectHolder* GetHolder() { return this; } diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index 92ca34effa..be56c531d2 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -575,7 +575,7 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, } } - pPage->SetRenderContext(std::unique_ptr()); + pPage->SetRenderContext(nullptr); } #endif // defined(_WIN32) @@ -604,7 +604,7 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, rotate, flags, TRUE, nullptr); - pPage->SetRenderContext(std::unique_ptr()); + pPage->SetRenderContext(nullptr); } #ifdef _SKIA_SUPPORT_ @@ -622,7 +622,7 @@ DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page, pContext->m_pDevice.reset(skDevice); FPDF_RenderPage_Retail(pContext, page, 0, 0, size_x, size_y, 0, 0, TRUE, nullptr); - pPage->SetRenderContext(std::unique_ptr()); + pPage->SetRenderContext(nullptr); return recorder; } #endif diff --git a/fpdfsdk/pdfwindow/PWL_FontMap.cpp b/fpdfsdk/pdfwindow/PWL_FontMap.cpp index a6f79e283c..b2a1f2580d 100644 --- a/fpdfsdk/pdfwindow/PWL_FontMap.cpp +++ b/fpdfsdk/pdfwindow/PWL_FontMap.cpp @@ -48,8 +48,7 @@ CPWL_FontMap::~CPWL_FontMap() { CPDF_Document* CPWL_FontMap::GetDocument() { if (!m_pPDFDoc) { if (CPDF_ModuleMgr::Get()) { - m_pPDFDoc = - pdfium::MakeUnique(std::unique_ptr()); + m_pPDFDoc = pdfium::MakeUnique(nullptr); m_pPDFDoc->CreateNewDoc(); } } diff --git a/xfa/fgas/crt/fgas_memory.cpp b/xfa/fgas/crt/fgas_memory.cpp index c68241fcf1..0cccdc75b0 100644 --- a/xfa/fgas/crt/fgas_memory.cpp +++ b/xfa/fgas/crt/fgas_memory.cpp @@ -100,7 +100,7 @@ std::unique_ptr IFX_MemoryAllocator::Create( #endif // MEMORY_TOOL_REPLACES_ALLOCATOR default: ASSERT(0); - return std::unique_ptr(); + return nullptr; } } -- cgit v1.2.3