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

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

Issue 2384883003: Remove CPDF_Object::Release() in favor of direct delete (Closed)
Patch Set: Remove ScopedDict typedefs Created 4 years, 2 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 unified diff | Download patch
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/fpdf_page/pageint.h" 7 #include "core/fpdfapi/fpdf_page/pageint.h"
8 8
9 #include <limits.h> 9 #include <limits.h>
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 const uint8_t* pData, 52 const uint8_t* pData,
53 uint32_t dwSize, 53 uint32_t dwSize,
54 const CFX_WeakPtr<CFX_ByteStringPool>& pPool) 54 const CFX_WeakPtr<CFX_ByteStringPool>& pPool)
55 : m_pBuf(pData), 55 : m_pBuf(pData),
56 m_Size(dwSize), 56 m_Size(dwSize),
57 m_Pos(0), 57 m_Pos(0),
58 m_pLastObj(nullptr), 58 m_pLastObj(nullptr),
59 m_pPool(pPool) {} 59 m_pPool(pPool) {}
60 60
61 CPDF_StreamParser::~CPDF_StreamParser() { 61 CPDF_StreamParser::~CPDF_StreamParser() {
62 if (m_pLastObj) { 62 delete m_pLastObj;
63 m_pLastObj->Release();
64 }
65 } 63 }
66 64
67 uint32_t DecodeAllScanlines(CCodec_ScanlineDecoder* pDecoder, 65 uint32_t DecodeAllScanlines(CCodec_ScanlineDecoder* pDecoder,
68 uint8_t*& dest_buf, 66 uint8_t*& dest_buf,
69 uint32_t& dest_size) { 67 uint32_t& dest_size) {
70 if (!pDecoder) { 68 if (!pDecoder) {
71 return FX_INVALID_OFFSET; 69 return FX_INVALID_OFFSET;
72 } 70 }
73 int ncomps = pDecoder->CountComps(); 71 int ncomps = pDecoder->CountComps();
74 int bpc = pDecoder->GetBPC(); 72 int bpc = pDecoder->GetBPC();
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 m_Pos = dwSavePos; 242 m_Pos = dwSavePos;
245 pData = FX_Alloc(uint8_t, dwStreamSize); 243 pData = FX_Alloc(uint8_t, dwStreamSize);
246 FXSYS_memcpy(pData, m_pBuf + m_Pos, dwStreamSize); 244 FXSYS_memcpy(pData, m_pBuf + m_Pos, dwStreamSize);
247 m_Pos += dwStreamSize; 245 m_Pos += dwStreamSize;
248 } 246 }
249 pDict->SetIntegerFor("Length", (int)dwStreamSize); 247 pDict->SetIntegerFor("Length", (int)dwStreamSize);
250 return new CPDF_Stream(pData, dwStreamSize, pDict); 248 return new CPDF_Stream(pData, dwStreamSize, pDict);
251 } 249 }
252 250
253 CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() { 251 CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() {
254 if (m_pLastObj) { 252 delete m_pLastObj;
255 m_pLastObj->Release(); 253 m_pLastObj = nullptr;
256 m_pLastObj = nullptr;
257 }
258 254
259 m_WordSize = 0; 255 m_WordSize = 0;
260 FX_BOOL bIsNumber = TRUE; 256 FX_BOOL bIsNumber = TRUE;
261 if (!PositionIsInBounds()) 257 if (!PositionIsInBounds())
262 return EndOfData; 258 return EndOfData;
263 259
264 int ch = m_pBuf[m_Pos++]; 260 int ch = m_pBuf[m_Pos++];
265 while (1) { 261 while (1) {
266 while (PDFCharIsWhitespace(ch)) { 262 while (PDFCharIsWhitespace(ch)) {
267 if (!PositionIsInBounds()) 263 if (!PositionIsInBounds())
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 if (m_WordSize == 1) 356 if (m_WordSize == 1)
361 return new CPDF_String(ReadHexString(), TRUE); 357 return new CPDF_String(ReadHexString(), TRUE);
362 358
363 CPDF_Dictionary* pDict = new CPDF_Dictionary(m_pPool); 359 CPDF_Dictionary* pDict = new CPDF_Dictionary(m_pPool);
364 while (1) { 360 while (1) {
365 GetNextWord(bIsNumber); 361 GetNextWord(bIsNumber);
366 if (m_WordSize == 2 && m_WordBuffer[0] == '>') 362 if (m_WordSize == 2 && m_WordBuffer[0] == '>')
367 break; 363 break;
368 364
369 if (!m_WordSize || m_WordBuffer[0] != '/') { 365 if (!m_WordSize || m_WordBuffer[0] != '/') {
370 pDict->Release(); 366 delete pDict;
371 return nullptr; 367 return nullptr;
372 } 368 }
373 369
374 CFX_ByteString key = 370 CFX_ByteString key =
375 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)); 371 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1));
376 CPDF_Object* pObj = ReadNextObject(true, 0); 372 CPDF_Object* pObj = ReadNextObject(true, 0);
377 if (!pObj) { 373 if (!pObj) {
378 pDict->Release(); 374 delete pDict;
379 return nullptr; 375 return nullptr;
380 } 376 }
381 377
382 if (key.IsEmpty()) 378 if (key.IsEmpty())
383 pObj->Release(); 379 delete pObj;
384 else 380 else
385 pDict->SetFor(key, pObj); 381 pDict->SetFor(key, pObj);
386 } 382 }
387 return pDict; 383 return pDict;
388 } 384 }
389 385
390 if (first_char == '[') { 386 if (first_char == '[') {
391 if ((!bAllowNestedArray && dwInArrayLevel) || 387 if ((!bAllowNestedArray && dwInArrayLevel) ||
392 dwInArrayLevel > kMaxNestedArrayLevel) { 388 dwInArrayLevel > kMaxNestedArrayLevel) {
393 return nullptr; 389 return nullptr;
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 } 826 }
831 m_Status = Done; 827 m_Status = Done;
832 return; 828 return;
833 } 829 }
834 steps++; 830 steps++;
835 if (pPause && pPause->NeedToPauseNow()) { 831 if (pPause && pPause->NeedToPauseNow()) {
836 break; 832 break;
837 } 833 }
838 } 834 }
839 } 835 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698