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

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

Issue 2420743002: Make CPDF_Image() constructors saner. (Closed)
Patch Set: Fix leak 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 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 #ifndef CORE_FPDFAPI_PARSER_CPDF_ARRAY_H_ 7 #ifndef CORE_FPDFAPI_PARSER_CPDF_ARRAY_H_
8 #define CORE_FPDFAPI_PARSER_CPDF_ARRAY_H_ 8 #define CORE_FPDFAPI_PARSER_CPDF_ARRAY_H_
9 9
10 #include <set> 10 #include <set>
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 protected: 63 protected:
64 ~CPDF_Array() override; 64 ~CPDF_Array() override;
65 65
66 CPDF_Object* CloneNonCyclic( 66 CPDF_Object* CloneNonCyclic(
67 bool bDirect, 67 bool bDirect,
68 std::set<const CPDF_Object*>* pVisited) const override; 68 std::set<const CPDF_Object*>* pVisited) const override;
69 69
70 std::vector<CPDF_Object*> m_Objects; 70 std::vector<CPDF_Object*> m_Objects;
71 }; 71 };
72 using UniqueArray = std::unique_ptr<CPDF_Array, ReleaseDeleter<CPDF_Object>>;
72 73
73 inline CPDF_Array* ToArray(CPDF_Object* obj) { 74 inline CPDF_Array* ToArray(CPDF_Object* obj) {
74 return obj ? obj->AsArray() : nullptr; 75 return obj ? obj->AsArray() : nullptr;
75 } 76 }
76 77
77 inline const CPDF_Array* ToArray(const CPDF_Object* obj) { 78 inline const CPDF_Array* ToArray(const CPDF_Object* obj) {
78 return obj ? obj->AsArray() : nullptr; 79 return obj ? obj->AsArray() : nullptr;
79 } 80 }
80 81
82 inline UniqueArray ToArray(UniqueObject obj) {
83 CPDF_Array* pArray = ToArray(obj.get());
84 if (!pArray)
85 return nullptr;
86 obj.release();
87 return UniqueArray(pArray);
88 }
89
81 #endif // CORE_FPDFAPI_PARSER_CPDF_ARRAY_H_ 90 #endif // CORE_FPDFAPI_PARSER_CPDF_ARRAY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698