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

Unified Diff: core/fpdfapi/parser/cpdf_indirect_object_holder.cpp

Issue 2489283003: Make AddIndirectObject() take a unique_ptr. (Closed)
Patch Set: Fix test 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 side-by-side diff with in-line comments
Download patch
Index: core/fpdfapi/parser/cpdf_indirect_object_holder.cpp
diff --git a/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp b/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp
index 529eda21fb156424d73a5e3759a971aecd058092..12b1e9f0896fc8c1d969b094c3a045707f85a29b 100644
--- a/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp
+++ b/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp
@@ -43,13 +43,14 @@ std::unique_ptr<CPDF_Object> CPDF_IndirectObjectHolder::ParseIndirectObject(
return nullptr;
}
-uint32_t CPDF_IndirectObjectHolder::AddIndirectObject(CPDF_Object* pObj) {
+CPDF_Object* CPDF_IndirectObjectHolder::AddIndirectObject(
+ std::unique_ptr<CPDF_Object> pObj) {
CHECK(!pObj->m_ObjNum);
- m_LastObjNum++;
+ CPDF_Object* pUnowned = pObj.get();
+ pObj->m_ObjNum = ++m_LastObjNum;
m_IndirectObjs[m_LastObjNum].release(); // TODO(tsepez): stop this leak.
- m_IndirectObjs[m_LastObjNum].reset(pObj);
- pObj->m_ObjNum = m_LastObjNum;
- return m_LastObjNum;
+ m_IndirectObjs[m_LastObjNum] = std::move(pObj);
+ return pUnowned;
}
bool CPDF_IndirectObjectHolder::ReplaceIndirectObjectIfHigherGeneration(

Powered by Google App Engine
This is Rietveld 408576698