From 2d5b020304e8a9aa8afeb632c61daa7ece87e36d Mon Sep 17 00:00:00 2001 From: weili Date: Wed, 3 Aug 2016 11:06:49 -0700 Subject: Use smart pointers for class owned pointers For all classes under /fpdfsdk, use smart pointer to replace raw pointer type for class owned member variables so that memory management will be easier. BUG=pdfium:518 Review-Url: https://codereview.chromium.org/2173253002 --- fpdfsdk/formfiller/cffl_iformfiller.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'fpdfsdk/formfiller/cffl_iformfiller.cpp') diff --git a/fpdfsdk/formfiller/cffl_iformfiller.cpp b/fpdfsdk/formfiller/cffl_iformfiller.cpp index 827c44a102..2fd4af1166 100644 --- a/fpdfsdk/formfiller/cffl_iformfiller.cpp +++ b/fpdfsdk/formfiller/cffl_iformfiller.cpp @@ -24,11 +24,7 @@ CFFL_IFormFiller::CFFL_IFormFiller(CPDFDoc_Environment* pApp) : m_pApp(pApp), m_bNotifying(FALSE) {} -CFFL_IFormFiller::~CFFL_IFormFiller() { - for (auto& it : m_Maps) - delete it.second; - m_Maps.clear(); -} +CFFL_IFormFiller::~CFFL_IFormFiller() {} FX_BOOL CFFL_IFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, @@ -511,7 +507,7 @@ CFFL_FormFiller* CFFL_IFormFiller::GetFormFiller(CPDFSDK_Annot* pAnnot, FX_BOOL bRegister) { auto it = m_Maps.find(pAnnot); if (it != m_Maps.end()) - return it->second; + return it->second.get(); if (!bRegister) return nullptr; @@ -547,7 +543,7 @@ CFFL_FormFiller* CFFL_IFormFiller::GetFormFiller(CPDFSDK_Annot* pAnnot, if (!pFormFiller) return nullptr; - m_Maps[pAnnot] = pFormFiller; + m_Maps[pAnnot].reset(pFormFiller); return pFormFiller; } @@ -562,7 +558,6 @@ void CFFL_IFormFiller::UnRegisterFormFiller(CPDFSDK_Annot* pAnnot) { if (it == m_Maps.end()) return; - delete it->second; m_Maps.erase(it); } -- cgit v1.2.3