diff options
Diffstat (limited to 'core/fpdfapi')
-rw-r--r-- | core/fpdfapi/render/cpdf_type3cache.cpp | 14 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_type3cache.h | 3 |
2 files changed, 8 insertions, 9 deletions
diff --git a/core/fpdfapi/render/cpdf_type3cache.cpp b/core/fpdfapi/render/cpdf_type3cache.cpp index d11103d014..b7a4cb808f 100644 --- a/core/fpdfapi/render/cpdf_type3cache.cpp +++ b/core/fpdfapi/render/cpdf_type3cache.cpp @@ -15,6 +15,7 @@ #include "core/fpdfapi/render/cpdf_type3glyphs.h" #include "core/fxge/fx_dib.h" #include "core/fxge/fx_font.h" +#include "third_party/base/ptr_util.h" namespace { @@ -81,11 +82,7 @@ int DetectFirstLastScan(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, CPDF_Type3Cache::CPDF_Type3Cache(CPDF_Type3Font* pFont) : m_pFont(pFont) {} -CPDF_Type3Cache::~CPDF_Type3Cache() { - for (const auto& pair : m_SizeMap) - delete pair.second; - m_SizeMap.clear(); -} +CPDF_Type3Cache::~CPDF_Type3Cache() {} CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(uint32_t charcode, const CFX_Matrix* pMatrix, @@ -99,10 +96,11 @@ CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(uint32_t charcode, CPDF_Type3Glyphs* pSizeCache; auto it = m_SizeMap.find(FaceGlyphsKey); if (it == m_SizeMap.end()) { - pSizeCache = new CPDF_Type3Glyphs; - m_SizeMap[FaceGlyphsKey] = pSizeCache; + auto pNew = pdfium::MakeUnique<CPDF_Type3Glyphs>(); + pSizeCache = pNew.get(); + m_SizeMap[FaceGlyphsKey] = std::move(pNew); } else { - pSizeCache = it->second; + pSizeCache = it->second.get(); } auto it2 = pSizeCache->m_GlyphMap.find(charcode); if (it2 != pSizeCache->m_GlyphMap.end()) diff --git a/core/fpdfapi/render/cpdf_type3cache.h b/core/fpdfapi/render/cpdf_type3cache.h index 0b3cdcbfa4..dc3e91b359 100644 --- a/core/fpdfapi/render/cpdf_type3cache.h +++ b/core/fpdfapi/render/cpdf_type3cache.h @@ -8,6 +8,7 @@ #define CORE_FPDFAPI_RENDER_CPDF_TYPE3CACHE_H_ #include <map> +#include <memory> #include "core/fpdfapi/font/cpdf_type3font.h" #include "core/fxcrt/cfx_retain_ptr.h" @@ -38,7 +39,7 @@ class CPDF_Type3Cache : public CFX_Retainable { float retinaScaleY); CPDF_Type3Font* const m_pFont; - std::map<CFX_ByteString, CPDF_Type3Glyphs*> m_SizeMap; + std::map<CFX_ByteString, std::unique_ptr<CPDF_Type3Glyphs>> m_SizeMap; }; #endif // CORE_FPDFAPI_RENDER_CPDF_TYPE3CACHE_H_ |