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

Side by Side Diff: core/fpdfapi/page/fpdf_page_parser_old.cpp

Issue 2384883003: Remove CPDF_Object::Release() in favor of direct delete (Closed)
Patch Set: rebase 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/page/cpdf_streamcontentparser.cpp ('k') | core/fpdfapi/parser/cfdf_document.cpp » ('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 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 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/page/pageint.h" 7 #include "core/fpdfapi/page/pageint.h"
8 8
9 #include <limits.h> 9 #include <limits.h>
10 10
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 const uint8_t* pData, 131 const uint8_t* pData,
132 uint32_t dwSize, 132 uint32_t dwSize,
133 const CFX_WeakPtr<CFX_ByteStringPool>& pPool) 133 const CFX_WeakPtr<CFX_ByteStringPool>& pPool)
134 : m_pBuf(pData), 134 : m_pBuf(pData),
135 m_Size(dwSize), 135 m_Size(dwSize),
136 m_Pos(0), 136 m_Pos(0),
137 m_pLastObj(nullptr), 137 m_pLastObj(nullptr),
138 m_pPool(pPool) {} 138 m_pPool(pPool) {}
139 139
140 CPDF_StreamParser::~CPDF_StreamParser() { 140 CPDF_StreamParser::~CPDF_StreamParser() {
141 if (m_pLastObj) { 141 delete m_pLastObj;
142 m_pLastObj->Release();
143 }
144 } 142 }
145 143
146 CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc, 144 CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc,
147 CPDF_Dictionary* pDict, 145 CPDF_Dictionary* pDict,
148 CPDF_Object* pCSObj) { 146 CPDF_Object* pCSObj) {
149 if (m_Pos == m_Size) 147 if (m_Pos == m_Size)
150 return nullptr; 148 return nullptr;
151 149
152 if (PDFCharIsWhitespace(m_pBuf[m_Pos])) 150 if (PDFCharIsWhitespace(m_pBuf[m_Pos]))
153 m_Pos++; 151 m_Pos++;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 m_Pos = dwSavePos; 243 m_Pos = dwSavePos;
246 pData = FX_Alloc(uint8_t, dwStreamSize); 244 pData = FX_Alloc(uint8_t, dwStreamSize);
247 FXSYS_memcpy(pData, m_pBuf + m_Pos, dwStreamSize); 245 FXSYS_memcpy(pData, m_pBuf + m_Pos, dwStreamSize);
248 m_Pos += dwStreamSize; 246 m_Pos += dwStreamSize;
249 } 247 }
250 pDict->SetIntegerFor("Length", (int)dwStreamSize); 248 pDict->SetIntegerFor("Length", (int)dwStreamSize);
251 return new CPDF_Stream(pData, dwStreamSize, pDict); 249 return new CPDF_Stream(pData, dwStreamSize, pDict);
252 } 250 }
253 251
254 CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() { 252 CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() {
255 if (m_pLastObj) { 253 delete m_pLastObj;
256 m_pLastObj->Release(); 254 m_pLastObj = nullptr;
257 m_pLastObj = nullptr;
258 }
259 255
260 m_WordSize = 0; 256 m_WordSize = 0;
261 bool bIsNumber = true; 257 bool bIsNumber = true;
262 if (!PositionIsInBounds()) 258 if (!PositionIsInBounds())
263 return EndOfData; 259 return EndOfData;
264 260
265 int ch = m_pBuf[m_Pos++]; 261 int ch = m_pBuf[m_Pos++];
266 while (1) { 262 while (1) {
267 while (PDFCharIsWhitespace(ch)) { 263 while (PDFCharIsWhitespace(ch)) {
268 if (!PositionIsInBounds()) 264 if (!PositionIsInBounds())
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 if (m_WordSize == 1) 363 if (m_WordSize == 1)
368 return new CPDF_String(ReadHexString(), true); 364 return new CPDF_String(ReadHexString(), true);
369 365
370 CPDF_Dictionary* pDict = new CPDF_Dictionary(m_pPool); 366 CPDF_Dictionary* pDict = new CPDF_Dictionary(m_pPool);
371 while (1) { 367 while (1) {
372 GetNextWord(bIsNumber); 368 GetNextWord(bIsNumber);
373 if (m_WordSize == 2 && m_WordBuffer[0] == '>') 369 if (m_WordSize == 2 && m_WordBuffer[0] == '>')
374 break; 370 break;
375 371
376 if (!m_WordSize || m_WordBuffer[0] != '/') { 372 if (!m_WordSize || m_WordBuffer[0] != '/') {
377 pDict->Release(); 373 delete pDict;
378 return nullptr; 374 return nullptr;
379 } 375 }
380 376
381 CFX_ByteString key = 377 CFX_ByteString key =
382 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)); 378 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1));
383 CPDF_Object* pObj = ReadNextObject(true, 0); 379 CPDF_Object* pObj = ReadNextObject(true, 0);
384 if (!pObj) { 380 if (!pObj) {
385 pDict->Release(); 381 delete pDict;
386 return nullptr; 382 return nullptr;
387 } 383 }
388 384
389 if (key.IsEmpty()) 385 if (key.IsEmpty())
390 pObj->Release(); 386 delete pObj;
391 else 387 else
392 pDict->SetFor(key, pObj); 388 pDict->SetFor(key, pObj);
393 } 389 }
394 return pDict; 390 return pDict;
395 } 391 }
396 392
397 if (first_char == '[') { 393 if (first_char == '[') {
398 if ((!bAllowNestedArray && dwInArrayLevel) || 394 if ((!bAllowNestedArray && dwInArrayLevel) ||
399 dwInArrayLevel > kMaxNestedArrayLevel) { 395 dwInArrayLevel > kMaxNestedArrayLevel) {
400 return nullptr; 396 return nullptr;
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 } 833 }
838 m_Status = Done; 834 m_Status = Done;
839 return; 835 return;
840 } 836 }
841 steps++; 837 steps++;
842 if (pPause && pPause->NeedToPauseNow()) { 838 if (pPause && pPause->NeedToPauseNow()) {
843 break; 839 break;
844 } 840 }
845 } 841 }
846 } 842 }
OLDNEW
« no previous file with comments | « core/fpdfapi/page/cpdf_streamcontentparser.cpp ('k') | core/fpdfapi/parser/cfdf_document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698