diff options
author | tsepez <tsepez@chromium.org> | 2016-11-18 16:22:41 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-11-18 16:22:41 -0800 |
commit | 0e606b5ecd6e45f74391f110cc1fe0cce0e80c64 (patch) | |
tree | 07c55fac710b191cf5d1d6595c63b90ca52e3cbb /core/fpdfapi/parser/cpdf_parser.cpp | |
parent | 430ab8363e77c48b2c2435af4d289f85e2be1b96 (diff) | |
download | pdfium-0e606b5ecd6e45f74391f110cc1fe0cce0e80c64.tar.xz |
Make CPDF_Dictionary use unique pointers.chromium/2926
Some changes were required to match underlying ctors
as invoked by the templated methods.
Many release() calls go away, a few WrapUniques() are
introduced to avoid going deeper into other code.
Review-Url: https://codereview.chromium.org/2510223002
Diffstat (limited to 'core/fpdfapi/parser/cpdf_parser.cpp')
-rw-r--r-- | core/fpdfapi/parser/cpdf_parser.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp index c43614f628..5354417eda 100644 --- a/core/fpdfapi/parser/cpdf_parser.cpp +++ b/core/fpdfapi/parser/cpdf_parser.cpp @@ -6,6 +6,8 @@ #include "core/fpdfapi/parser/cpdf_parser.h" +#include <algorithm> +#include <utility> #include <vector> #include "core/fpdfapi/parser/cpdf_array.h" @@ -802,16 +804,15 @@ bool CPDF_Parser::RebuildCrossRef() { auto it = pTrailer->begin(); while (it != pTrailer->end()) { const CFX_ByteString& key = it->first; - CPDF_Object* pElement = it->second; + CPDF_Object* pElement = it->second.get(); ++it; uint32_t dwObjNum = pElement ? pElement->GetObjNum() : 0; if (dwObjNum) { - m_pTrailer->SetReferenceFor(key, m_pDocument, - dwObjNum); + m_pTrailer->SetNewFor<CPDF_Reference>( + key, m_pDocument, dwObjNum); } else { - m_pTrailer->SetFor(key, - pElement->Clone().release()); + m_pTrailer->SetFor(key, pElement->Clone()); } } } @@ -1075,7 +1076,7 @@ CPDF_Array* CPDF_Parser::GetIDArray() { if (CPDF_Reference* pRef = pID->AsReference()) { pID = ParseIndirectObject(nullptr, pRef->GetRefObjNum()).release(); - m_pTrailer->SetFor("ID", pID); + m_pTrailer->SetFor("ID", pdfium::WrapUnique(pID)); } return ToArray(pID); } |