summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfppo.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-11-15 11:33:44 -0800
committerCommit bot <commit-bot@chromium.org>2016-11-15 11:33:44 -0800
commit70c4afd5c3c5c44cd24f814423a23a6ef05bba02 (patch)
treecbe593d0b6c0bfc6fd5038bf60a77a94e49c69c9 /fpdfsdk/fpdfppo.cpp
parentf16f6b8b52277348f5d571b7641bb0bbd5239589 (diff)
downloadpdfium-70c4afd5c3c5c44cd24f814423a23a6ef05bba02.tar.xz
Make AddIndirectObject() take a unique_ptr.
Add convenience routines to create and add object in one step. Review-Url: https://codereview.chromium.org/2489283003
Diffstat (limited to 'fpdfsdk/fpdfppo.cpp')
-rw-r--r--fpdfsdk/fpdfppo.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/fpdfsdk/fpdfppo.cpp b/fpdfsdk/fpdfppo.cpp
index 705c7e21da..610aae7abd 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;