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

Side by Side Diff: core/fpdfapi/parser/cpdf_array.cpp

Issue 2489283003: Make AddIndirectObject() take a unique_ptr. (Closed)
Patch Set: Address review comments 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 unified diff | Download patch
« no previous file with comments | « core/fpdfapi/parser/cpdf_array.h ('k') | core/fpdfapi/parser/cpdf_dictionary.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fpdfapi/parser/cpdf_array.h" 7 #include "core/fpdfapi/parser/cpdf_array.h"
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 void CPDF_Array::ConvertToIndirectObjectAt(size_t i, 149 void CPDF_Array::ConvertToIndirectObjectAt(size_t i,
150 CPDF_IndirectObjectHolder* pHolder) { 150 CPDF_IndirectObjectHolder* pHolder) {
151 if (i >= m_Objects.size()) 151 if (i >= m_Objects.size())
152 return; 152 return;
153 153
154 CPDF_Object* pObj = m_Objects[i]; 154 CPDF_Object* pObj = m_Objects[i];
155 if (!pObj || pObj->IsReference()) 155 if (!pObj || pObj->IsReference())
156 return; 156 return;
157 157
158 uint32_t dwObjNum = pHolder->AddIndirectObject(pObj); 158 CPDF_Object* pNew = pHolder->AddIndirectObject(pdfium::WrapUnique(pObj));
159 m_Objects[i] = new CPDF_Reference(pHolder, dwObjNum); 159 m_Objects[i] = new CPDF_Reference(pHolder, pNew->GetObjNum());
160 } 160 }
161 161
162 void CPDF_Array::SetAt(size_t i, CPDF_Object* pObj) { 162 void CPDF_Array::SetAt(size_t i, CPDF_Object* pObj) {
163 ASSERT(IsArray()); 163 ASSERT(IsArray());
164 CHECK(!pObj || pObj->IsInline()); 164 CHECK(!pObj || pObj->IsInline());
165 if (i >= m_Objects.size()) { 165 if (i >= m_Objects.size()) {
166 ASSERT(false); 166 ASSERT(false);
167 return; 167 return;
168 } 168 }
169 delete m_Objects[i]; 169 delete m_Objects[i];
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 202 }
203 203
204 void CPDF_Array::AddNumber(FX_FLOAT f) { 204 void CPDF_Array::AddNumber(FX_FLOAT f) {
205 Add(new CPDF_Number(f)); 205 Add(new CPDF_Number(f));
206 } 206 }
207 207
208 void CPDF_Array::AddReference(CPDF_IndirectObjectHolder* pDoc, 208 void CPDF_Array::AddReference(CPDF_IndirectObjectHolder* pDoc,
209 uint32_t objnum) { 209 uint32_t objnum) {
210 Add(new CPDF_Reference(pDoc, objnum)); 210 Add(new CPDF_Reference(pDoc, objnum));
211 } 211 }
212
213 void CPDF_Array::AddReference(CPDF_IndirectObjectHolder* pDoc,
214 CPDF_Object* pObj) {
215 ASSERT(!pObj->IsInline());
216 Add(new CPDF_Reference(pDoc, pObj->GetObjNum()));
217 }
OLDNEW
« no previous file with comments | « core/fpdfapi/parser/cpdf_array.h ('k') | core/fpdfapi/parser/cpdf_dictionary.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698