diff options
author | jaepark <jaepark@google.com> | 2016-07-26 17:01:22 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-26 17:01:22 -0700 |
commit | c279a3e1bd3da4e7f7504e438e6df8b7079027f9 (patch) | |
tree | 1b38d854fc15bf77bf92dd271b793d5b14821d22 /core/fpdfdoc | |
parent | 6c694f1b3e097da1be5381de83e9e0da85c5a6f8 (diff) | |
download | pdfium-c279a3e1bd3da4e7f7504e438e6df8b7079027f9.tar.xz |
Use smart pointer for CPDF_Form in CPDF_Annot.
CPDF_Annot owns CPDF_Form, so use std::unique_ptr for memory management.
BUG=pdfium:518
Review-Url: https://codereview.chromium.org/2189463003
Diffstat (limited to 'core/fpdfdoc')
-rw-r--r-- | core/fpdfdoc/cpdf_annot.cpp | 8 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_annot.h | 2 |
2 files changed, 4 insertions, 6 deletions
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp index dcdd89c3f4..57e7bc0bbb 100644 --- a/core/fpdfdoc/cpdf_annot.cpp +++ b/core/fpdfdoc/cpdf_annot.cpp @@ -12,6 +12,7 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h" #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" +#include "core/fxcrt/include/fx_memory.h" #include "core/fxge/include/fx_ge.h" CPDF_Annot::CPDF_Annot(CPDF_Dictionary* pDict, CPDF_Document* pDocument) @@ -24,9 +25,6 @@ CPDF_Annot::~CPDF_Annot() { } void CPDF_Annot::ClearCachedAP() { - for (const auto& pair : m_APMap) { - delete pair.second; - } m_APMap.clear(); } CFX_ByteString CPDF_Annot::GetSubType() const { @@ -90,12 +88,12 @@ CPDF_Form* CPDF_Annot::GetAPForm(const CPDF_Page* pPage, AppearanceMode mode) { auto it = m_APMap.find(pStream); if (it != m_APMap.end()) - return it->second; + return it->second.get(); CPDF_Form* pNewForm = new CPDF_Form(m_pDocument, pPage->m_pResources, pStream); pNewForm->ParseContent(nullptr, nullptr, nullptr); - m_APMap[pStream] = pNewForm; + m_APMap[pStream] = WrapUnique(pNewForm); return pNewForm; } diff --git a/core/fpdfdoc/cpdf_annot.h b/core/fpdfdoc/cpdf_annot.h index b5d9186fd3..eab76a6376 100644 --- a/core/fpdfdoc/cpdf_annot.h +++ b/core/fpdfdoc/cpdf_annot.h @@ -64,7 +64,7 @@ class CPDF_Annot { CPDF_Dictionary* const m_pAnnotDict; CPDF_Document* const m_pDocument; const CFX_ByteString m_sSubtype; - std::map<CPDF_Stream*, CPDF_Form*> m_APMap; + std::map<CPDF_Stream*, std::unique_ptr<CPDF_Form>> m_APMap; }; #endif // CORE_FPDFDOC_CPDF_ANNOT_H_ |