Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Unified Diff: fpdfsdk/fpdfppo.cpp

Issue 2489283003: Make AddIndirectObject() take a unique_ptr. (Closed)
Patch Set: Address review comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/fpdfdoc_unittest.cpp ('k') | fpdfsdk/fpdfsave.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/fpdfppo.cpp
diff --git a/fpdfsdk/fpdfppo.cpp b/fpdfsdk/fpdfppo.cpp
index 705c7e21daa90fcc1d4abc2981e844bd68f3dba9..610aae7abdcd4acf5ba21e08fd990c3393b23282 100644
--- a/fpdfsdk/fpdfppo.cpp
+++ b/fpdfsdk/fpdfppo.cpp
@@ -170,9 +170,9 @@ bool CPDF_PageOrganizer::PDFDocInit() {
CPDF_Dictionary* pNewPages =
pElement ? ToDictionary(pElement->GetDirect()) : nullptr;
if (!pNewPages) {
- pNewPages = new CPDF_Dictionary(m_pDestPDFDoc->GetByteStringPool());
- pNewRoot->SetReferenceFor("Pages", m_pDestPDFDoc,
- m_pDestPDFDoc->AddIndirectObject(pNewPages));
+ pNewPages = m_pDestPDFDoc->NewIndirect<CPDF_Dictionary>(
+ m_pDestPDFDoc->GetByteStringPool());
+ pNewRoot->SetReferenceFor("Pages", m_pDestPDFDoc, pNewPages);
}
CFX_ByteString cbPageType = pNewPages->GetStringFor("Type", "");
@@ -181,9 +181,8 @@ bool CPDF_PageOrganizer::PDFDocInit() {
if (!pNewPages->GetArrayFor("Kids")) {
pNewPages->SetIntegerFor("Count", 0);
- pNewPages->SetReferenceFor(
- "Kids", m_pDestPDFDoc,
- m_pDestPDFDoc->AddIndirectObject(new CPDF_Array));
+ pNewPages->SetReferenceFor("Kids", m_pDestPDFDoc,
+ m_pDestPDFDoc->NewIndirect<CPDF_Array>());
}
return true;
@@ -331,8 +330,9 @@ uint32_t CPDF_PageOrganizer::GetNewObjId(ObjectNumberMap* pObjNumberMap,
return 0;
}
}
- CPDF_Object* pUnownedClone = pClone.get();
- dwNewObjNum = m_pDestPDFDoc->AddIndirectObject(pClone.release());
+ CPDF_Object* pUnownedClone =
+ m_pDestPDFDoc->AddIndirectObject(std::move(pClone));
+ dwNewObjNum = pUnownedClone->GetObjNum();
(*pObjNumberMap)[dwObjnum] = dwNewObjNum;
if (!UpdateReference(pUnownedClone, pObjNumberMap))
return 0;
« no previous file with comments | « fpdfsdk/fpdfdoc_unittest.cpp ('k') | fpdfsdk/fpdfsave.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698