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

Unified Diff: core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp

Issue 2358243002: Use unique_ptr<CPDF_Object, ReleaseDeleter<>> in more places (Closed)
Patch Set: Created 4 years, 3 months 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 | « no previous file | core/fpdfapi/fpdf_edit/include/cpdf_creator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
index c43306317a22044cf7b0ab98105a21bce533e6f6..d29b9834fa1e731e0e0ee48e67556da4fe0e2405 100644
--- a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
+++ b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
@@ -814,7 +814,7 @@ FX_BOOL CPDF_XRefStream::GenerateXRefStream(CPDF_Creator* pCreator,
offset += len + 8;
if (bEOF) {
if ((len = PDF_CreatorWriteTrailer(pCreator->m_pDocument, pFile,
- pCreator->m_pIDArray)) < 0) {
+ pCreator->m_pIDArray.get())) < 0) {
return FALSE;
}
offset += len;
@@ -1810,7 +1810,7 @@ int32_t CPDF_Creator::WriteDoc_Stage4(IFX_Pause* pPause) {
return -1;
}
FX_FILESIZE offset = 0;
- if (PDF_CreatorAppendObject(m_pIDArray, &m_File, offset) < 0) {
+ if (PDF_CreatorAppendObject(m_pIDArray.get(), &m_File, offset) < 0) {
return -1;
}
}
@@ -1904,10 +1904,7 @@ void CPDF_Creator::Clear() {
m_pXRefStream.reset();
m_File.Clear();
m_NewObjNumArray.RemoveAll();
- if (m_pIDArray) {
- m_pIDArray->Release();
- m_pIDArray = nullptr;
- }
+ m_pIDArray.reset();
}
bool CPDF_Creator::Create(IFX_StreamWrite* pFile, uint32_t flags) {
@@ -1931,8 +1928,8 @@ bool CPDF_Creator::Create(uint32_t flags) {
void CPDF_Creator::InitID(FX_BOOL bDefault) {
CPDF_Array* pOldIDArray = m_pParser ? m_pParser->GetIDArray() : nullptr;
FX_BOOL bNewId = !m_pIDArray;
- if (!m_pIDArray) {
- m_pIDArray = new CPDF_Array;
+ if (bNewId) {
+ m_pIDArray.reset(new CPDF_Array);
CPDF_Object* pID1 = pOldIDArray ? pOldIDArray->GetObjectAt(0) : nullptr;
if (pID1) {
m_pIDArray->Add(pID1->Clone());
@@ -1965,7 +1962,7 @@ void CPDF_Creator::InitID(FX_BOOL bDefault) {
uint32_t flag = PDF_ENCRYPT_CONTENT;
CPDF_SecurityHandler handler;
- handler.OnCreate(m_pEncryptDict, m_pIDArray, user_pass.raw_str(),
+ handler.OnCreate(m_pEncryptDict, m_pIDArray.get(), user_pass.raw_str(),
user_pass.GetLength(), flag);
if (m_bLocalCryptoHandler)
delete m_pCryptoHandler;
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_edit/include/cpdf_creator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698