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

Unified Diff: fpdfsdk/fpdfsave.cpp

Issue 2520493002: Make CPDF_Stream() take unique_ptr's to its dictionary. (Closed)
Patch Set: 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
« core/fpdfapi/parser/cpdf_stream.h ('K') | « fpdfsdk/fpdf_transformpage.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/fpdfsave.cpp
diff --git a/fpdfsdk/fpdfsave.cpp b/fpdfsdk/fpdfsave.cpp
index c9043249e1c7ddfcbba51e0ea54cdf284aeabe4b..82baf6bedc011468dd5885ea61dc751c1058e2b6 100644
--- a/fpdfsdk/fpdfsave.cpp
+++ b/fpdfsdk/fpdfsave.cpp
@@ -174,14 +174,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,
@@ -196,14 +198,15 @@ 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)
Lei Zhang 2016/11/18 23:50:34 curly braces, like line 180.
Tom Sepez 2016/11/19 00:05:16 Done.
- pFormStream->InitStreamFromFile(pfileWrite.get(), pDataDict);
+ 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,
« core/fpdfapi/parser/cpdf_stream.h ('K') | « fpdfsdk/fpdf_transformpage.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698