From 0e606b5ecd6e45f74391f110cc1fe0cce0e80c64 Mon Sep 17 00:00:00 2001 From: tsepez Date: Fri, 18 Nov 2016 16:22:41 -0800 Subject: Make CPDF_Dictionary use unique pointers. Some changes were required to match underlying ctors as invoked by the templated methods. Many release() calls go away, a few WrapUniques() are introduced to avoid going deeper into other code. Review-Url: https://codereview.chromium.org/2510223002 --- core/fpdfapi/font/cpdf_font.cpp | 9 +++++---- core/fpdfapi/font/cpdf_fontencoding.cpp | 8 +++++--- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'core/fpdfapi/font') diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp index c5da4ea519..c7725c3fce 100644 --- a/core/fpdfapi/font/cpdf_font.cpp +++ b/core/fpdfapi/font/cpdf_font.cpp @@ -7,6 +7,7 @@ #include "core/fpdfapi/font/cpdf_font.h" #include +#include #include #include "core/fpdfapi/cpdf_modulemgr.h" @@ -310,10 +311,10 @@ CPDF_Font* CPDF_Font::GetStockFont(CPDF_Document* pDoc, return pFont; CPDF_Dictionary* pDict = new CPDF_Dictionary(pDoc->GetByteStringPool()); - pDict->SetNameFor("Type", "Font"); - pDict->SetNameFor("Subtype", "Type1"); - pDict->SetNameFor("BaseFont", fontname); - pDict->SetNameFor("Encoding", "WinAnsiEncoding"); + pDict->SetNewFor("Type", "Font"); + pDict->SetNewFor("Subtype", "Type1"); + pDict->SetNewFor("BaseFont", fontname); + pDict->SetNewFor("Encoding", "WinAnsiEncoding"); return pFontGlobals->Set(pDoc, font_id, CPDF_Font::Create(nullptr, pDict)); } diff --git a/core/fpdfapi/font/cpdf_fontencoding.cpp b/core/fpdfapi/font/cpdf_fontencoding.cpp index da607e6aa8..df21267e1d 100644 --- a/core/fpdfapi/font/cpdf_fontencoding.cpp +++ b/core/fpdfapi/font/cpdf_fontencoding.cpp @@ -6,6 +6,8 @@ #include "core/fpdfapi/font/cpdf_fontencoding.h" +#include + #include "core/fpdfapi/parser/cpdf_array.h" #include "core/fpdfapi/parser/cpdf_dictionary.h" #include "core/fpdfapi/parser/cpdf_name.h" @@ -1701,7 +1703,7 @@ CPDF_Object* CPDF_FontEncoding::Realize(CFX_WeakPtr pPool) { } const uint16_t* pStandard = PDF_UnicodesForPredefinedCharSet(PDFFONT_ENCODING_WINANSI); - CPDF_Array* pDiff = new CPDF_Array; + auto pDiff = pdfium::MakeUnique(); for (int i = 0; i < 256; i++) { if (pStandard[i] == m_Unicodes[i]) continue; @@ -1711,8 +1713,8 @@ CPDF_Object* CPDF_FontEncoding::Realize(CFX_WeakPtr pPool) { } CPDF_Dictionary* pDict = new CPDF_Dictionary(pPool); - pDict->SetNameFor("BaseEncoding", "WinAnsiEncoding"); - pDict->SetFor("Differences", pDiff); + pDict->SetNewFor("BaseEncoding", "WinAnsiEncoding"); + pDict->SetFor("Differences", std::move(pDiff)); return pDict; } -- cgit v1.2.3