diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-03-24 11:07:31 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-24 19:16:51 +0000 |
commit | 4a58d1427f8a1b105578f2d27391ceda238ca59c (patch) | |
tree | 95d526e6dbe8f37008eed21194190c54b1f7864a /core/fpdfapi/font/fpdf_font_cid.cpp | |
parent | 73b607fcb5f904893a0610b2c7fb8726d09379e6 (diff) | |
download | pdfium-4a58d1427f8a1b105578f2d27391ceda238ca59c.tar.xz |
Refcount CPDF_CMap all the time.chromium/3052chromium/3051
Change-Id: I85ea9529f4188bf818ee96c37944e4546411f79c
Reviewed-on: https://pdfium-review.googlesource.com/3211
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi/font/fpdf_font_cid.cpp')
-rw-r--r-- | core/fpdfapi/font/fpdf_font_cid.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/core/fpdfapi/font/fpdf_font_cid.cpp b/core/fpdfapi/font/fpdf_font_cid.cpp index e6be712a13..ddc0c12b7d 100644 --- a/core/fpdfapi/font/fpdf_font_cid.cpp +++ b/core/fpdfapi/font/fpdf_font_cid.cpp @@ -286,30 +286,28 @@ CPDF_CMapManager::CPDF_CMapManager() {} CPDF_CMapManager::~CPDF_CMapManager() {} -CFX_MaybeOwned<CPDF_CMap> CPDF_CMapManager::GetPredefinedCMap( +CFX_RetainPtr<CPDF_CMap> CPDF_CMapManager::GetPredefinedCMap( const CFX_ByteString& name, bool bPromptCJK) { auto it = m_CMaps.find(name); if (it != m_CMaps.end()) - return CFX_MaybeOwned<CPDF_CMap>(it->second.get()); // Unowned. + return it->second; - std::unique_ptr<CPDF_CMap> pCMap = LoadPredefinedCMap(name, bPromptCJK); - if (name.IsEmpty()) - return CFX_MaybeOwned<CPDF_CMap>(std::move(pCMap)); // Owned. + CFX_RetainPtr<CPDF_CMap> pCMap = LoadPredefinedCMap(name, bPromptCJK); + if (!name.IsEmpty()) + m_CMaps[name] = pCMap; - CPDF_CMap* pUnowned = pCMap.get(); - m_CMaps[name] = std::move(pCMap); - return CFX_MaybeOwned<CPDF_CMap>(pUnowned); // Unowned. + return pCMap; } -std::unique_ptr<CPDF_CMap> CPDF_CMapManager::LoadPredefinedCMap( +CFX_RetainPtr<CPDF_CMap> CPDF_CMapManager::LoadPredefinedCMap( const CFX_ByteString& name, bool bPromptCJK) { - auto pCMap = pdfium::MakeUnique<CPDF_CMap>(); const char* pname = name.c_str(); if (*pname == '/') pname++; + auto pCMap = pdfium::MakeRetain<CPDF_CMap>(); pCMap->LoadPredefined(this, pname, bPromptCJK); return pCMap; } |