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

Side by Side Diff: core/fpdfapi/fpdf_parser/cfdf_document.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_parser/cfdf_document.h" 7 #include "core/fpdfapi/fpdf_parser/cfdf_document.h"
8 8
9 #include "core/fpdfapi/fpdf_edit/cpdf_creator.h" 9 #include "core/fpdfapi/fpdf_edit/cpdf_creator.h"
10 #include "core/fpdfapi/fpdf_parser/cpdf_dictionary.h" 10 #include "core/fpdfapi/fpdf_parser/cpdf_dictionary.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 word = parser.GetNextWord(nullptr); 72 word = parser.GetNextWord(nullptr);
73 if (word != "endobj") 73 if (word != "endobj")
74 break; 74 break;
75 } else { 75 } else {
76 if (word != "trailer") 76 if (word != "trailer")
77 break; 77 break;
78 78
79 if (CPDF_Dictionary* pMainDict = 79 if (CPDF_Dictionary* pMainDict =
80 ToDictionary(parser.GetObject(this, 0, 0, true))) { 80 ToDictionary(parser.GetObject(this, 0, 0, true))) {
81 m_pRootDict = pMainDict->GetDictFor("Root"); 81 m_pRootDict = pMainDict->GetDictFor("Root");
82 pMainDict->Release(); 82 delete pMainDict;
83 } 83 }
84 break; 84 break;
85 } 85 }
86 } 86 }
87 } 87 }
88 88
89 FX_BOOL CFDF_Document::WriteBuf(CFX_ByteTextBuf& buf) const { 89 FX_BOOL CFDF_Document::WriteBuf(CFX_ByteTextBuf& buf) const {
90 if (!m_pRootDict) 90 if (!m_pRootDict)
91 return FALSE; 91 return FALSE;
92 92
93 buf << "%FDF-1.2\r\n"; 93 buf << "%FDF-1.2\r\n";
94 for (const auto& pair : *this) 94 for (const auto& pair : *this)
95 buf << pair.first << " 0 obj\r\n" 95 buf << pair.first << " 0 obj\r\n"
96 << pair.second.get() << "\r\nendobj\r\n\r\n"; 96 << pair.second.get() << "\r\nendobj\r\n\r\n";
97 97
98 buf << "trailer\r\n<</Root " << m_pRootDict->GetObjNum() 98 buf << "trailer\r\n<</Root " << m_pRootDict->GetObjNum()
99 << " 0 R>>\r\n%%EOF\r\n"; 99 << " 0 R>>\r\n%%EOF\r\n";
100 return TRUE; 100 return TRUE;
101 } 101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698