summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfppo.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-10-14 16:59:10 -0700
committerCommit bot <commit-bot@chromium.org>2016-10-14 16:59:10 -0700
commit3ba098595ae56b64eacc0c25ab76b89a4d78d920 (patch)
tree5c4db47295ea64cdf236c32ef7d5af5b8e7af232 /fpdfsdk/fpdfppo.cpp
parent1d023881cd53485303c0fcc0b5878e700dc470fd (diff)
downloadpdfium-3ba098595ae56b64eacc0c25ab76b89a4d78d920.tar.xz
Update CPDF_IndirectObjectHolder APIs for unique objects.
Doing so highlights a few places where ownership is dubious. Add convenience functions to return an unowned reference to a newly-created indirect object. Review-Url: https://codereview.chromium.org/2419173002
Diffstat (limited to 'fpdfsdk/fpdfppo.cpp')
-rw-r--r--fpdfsdk/fpdfppo.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/fpdfsdk/fpdfppo.cpp b/fpdfsdk/fpdfppo.cpp
index 8a46ea4067..023c41a750 100644
--- a/fpdfsdk/fpdfppo.cpp
+++ b/fpdfsdk/fpdfppo.cpp
@@ -70,9 +70,9 @@ FX_BOOL CPDF_PageOrganizer::PDFDocInit(CPDF_Document* pDestPDFDoc,
CPDF_Dictionary* pNewPages =
pElement ? ToDictionary(pElement->GetDirect()) : nullptr;
if (!pNewPages) {
- pNewPages = new CPDF_Dictionary(pDestPDFDoc->GetByteStringPool());
- pNewRoot->SetReferenceFor("Pages", pDestPDFDoc,
- pDestPDFDoc->AddIndirectObject(pNewPages));
+ pNewPages =
+ pDestPDFDoc->AddIndirectDictionary(pDestPDFDoc->GetByteStringPool());
+ pNewRoot->SetReferenceFor("Pages", pDestPDFDoc, pNewPages);
}
CFX_ByteString cbPageType = pNewPages->GetStringFor("Type", "");
@@ -83,7 +83,7 @@ FX_BOOL CPDF_PageOrganizer::PDFDocInit(CPDF_Document* pDestPDFDoc,
if (!pNewPages->GetArrayFor("Kids")) {
pNewPages->SetIntegerFor("Count", 0);
pNewPages->SetReferenceFor("Kids", pDestPDFDoc,
- pDestPDFDoc->AddIndirectObject(new CPDF_Array));
+ pDestPDFDoc->AddIndirectArray());
}
return TRUE;
@@ -277,7 +277,7 @@ uint32_t CPDF_PageOrganizer::GetNewObjId(CPDF_Document* pDoc,
if (!pDirect)
return 0;
- CPDF_Object* pClone = pDirect->Clone();
+ UniqueObject pClone(pDirect->Clone());
if (!pClone)
return 0;
@@ -294,10 +294,11 @@ uint32_t CPDF_PageOrganizer::GetNewObjId(CPDF_Document* pDoc,
}
}
}
- dwNewObjNum = pDoc->AddIndirectObject(pClone);
+ CPDF_Object* pUnowned = pDoc->AddIndirectObject(std::move(pClone));
+ dwNewObjNum = pUnowned->GetObjNum();
(*pObjNumberMap)[dwObjnum] = dwNewObjNum;
- if (!UpdateReference(pClone, pDoc, pObjNumberMap)) {
- pClone->Release();
+ if (!UpdateReference(pUnowned, pDoc, pObjNumberMap)) {
+ pDoc->DeleteIndirectObject(dwNewObjNum);
return 0;
}
return dwNewObjNum;