From 5ce09684216ed6b74836de9bd056b8f15bd66a4e Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 25 May 2016 16:16:32 -0700 Subject: Remove CFX_PrivateData from CPDF_Document Replace it with two generic slots for Links and Codec usage. Since the codec is at a lower layer than the document, we don't provide separate get/set methods, since having a document upon which to call these would be a layering violation. Do the same for the Links for simplicity. Review-Url: https://codereview.chromium.org/2005193003 --- fpdfsdk/fpdfdoc.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/fpdfdoc.cpp b/fpdfsdk/fpdfdoc.cpp index 7473cb0671..0f69340821 100644 --- a/fpdfsdk/fpdfdoc.cpp +++ b/fpdfsdk/fpdfdoc.cpp @@ -16,8 +16,6 @@ namespace { -int THISMODULE = 0; - CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree, CPDF_Bookmark bookmark, const CFX_WideString& title, @@ -45,22 +43,15 @@ CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree, return CPDF_Bookmark(); } -void ReleaseLinkList(void* data) { - delete (CPDF_LinkList*)data; -} - CPDF_LinkList* GetLinkList(CPDF_Page* page) { if (!page) return nullptr; - // Link list is stored with the document CPDF_Document* pDoc = page->m_pDocument; - CPDF_LinkList* pLinkList = (CPDF_LinkList*)pDoc->GetPrivateData(&THISMODULE); - if (!pLinkList) { - pLinkList = new CPDF_LinkList; - pDoc->SetPrivateData(&THISMODULE, pLinkList, ReleaseLinkList); - } - return pLinkList; + std::unique_ptr* pHolder = pDoc->LinksContext(); + if (!pHolder->get()) + pHolder->reset(new CPDF_LinkList); + return pHolder->get(); } } // namespace -- cgit v1.2.3