summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfsave.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-11-21 13:19:10 -0800
committerCommit bot <commit-bot@chromium.org>2016-11-21 13:19:10 -0800
commit9e05ee1e7bfb74d56d69620ad1e72b03e29b9237 (patch)
tree12b47b617d99edc7bd2715292402b74e864e1fa4 /fpdfsdk/fpdfsave.cpp
parentaa3922dd713d480229408f3a0813b7dab9e8fd78 (diff)
downloadpdfium-9e05ee1e7bfb74d56d69620ad1e72b03e29b9237.tar.xz
Make CPDF_Stream() take unique_ptr's to its dictionary.
Review-Url: https://codereview.chromium.org/2520493002
Diffstat (limited to 'fpdfsdk/fpdfsave.cpp')
-rw-r--r--fpdfsdk/fpdfsave.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/fpdfsdk/fpdfsave.cpp b/fpdfsdk/fpdfsave.cpp
index 89b8b5839e..cb01ab697b 100644
--- a/fpdfsdk/fpdfsave.cpp
+++ b/fpdfsdk/fpdfsave.cpp
@@ -176,14 +176,16 @@ bool SaveXFADocumentData(CPDFXFA_Context* pContext,
// Datasets
pChecksum->UpdateChecksum(pDsfileWrite.get());
pChecksum->FinishChecksum();
- CPDF_Dictionary* pDataDict =
- new CPDF_Dictionary(pPDFDocument->GetByteStringPool());
+ auto pDataDict = pdfium::MakeUnique<CPDF_Dictionary>(
+ pPDFDocument->GetByteStringPool());
if (iDataSetsIndex != -1) {
- if (pDataSetsStream)
- pDataSetsStream->InitStreamFromFile(pDsfileWrite.get(), pDataDict);
+ if (pDataSetsStream) {
+ pDataSetsStream->InitStreamFromFile(pDsfileWrite.get(),
+ std::move(pDataDict));
+ }
} else {
CPDF_Stream* pData = pPDFDocument->NewIndirect<CPDF_Stream>();
- pData->InitStreamFromFile(pDsfileWrite.get(), pDataDict);
+ pData->InitStreamFromFile(pDsfileWrite.get(), std::move(pDataDict));
iLast = pArray->GetCount() - 2;
pArray->InsertNewAt<CPDF_String>(iLast, "datasets", false);
pArray->InsertNewAt<CPDF_Reference>(iLast + 1, pPDFDocument,
@@ -198,14 +200,16 @@ bool SaveXFADocumentData(CPDFXFA_Context* pContext,
if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, pfileWrite.get(),
pChecksum.get()) &&
pfileWrite->GetSize() > 0) {
- CPDF_Dictionary* pDataDict =
- new CPDF_Dictionary(pPDFDocument->GetByteStringPool());
+ auto pDataDict = pdfium::MakeUnique<CPDF_Dictionary>(
+ pPDFDocument->GetByteStringPool());
if (iFormIndex != -1) {
- if (pFormStream)
- pFormStream->InitStreamFromFile(pfileWrite.get(), pDataDict);
+ if (pFormStream) {
+ pFormStream->InitStreamFromFile(pfileWrite.get(),
+ std::move(pDataDict));
+ }
} else {
CPDF_Stream* pData = pPDFDocument->NewIndirect<CPDF_Stream>();
- pData->InitStreamFromFile(pfileWrite.get(), pDataDict);
+ pData->InitStreamFromFile(pfileWrite.get(), std::move(pDataDict));
iLast = pArray->GetCount() - 2;
pArray->InsertNewAt<CPDF_String>(iLast, "form", false);
pArray->InsertNewAt<CPDF_Reference>(iLast + 1, pPDFDocument,