summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-04-03 14:53:01 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-04-03 22:47:24 +0000
commit7b9d82312413a3cd2dc7422313bb634eaa687a87 (patch)
tree039fffc7f773e69bce016ed774f57799aa088ac7 /core/fpdfapi
parent05e6a807311df5c3dfc4cafa56b85614f9bae6d3 (diff)
downloadpdfium-7b9d82312413a3cd2dc7422313bb634eaa687a87.tar.xz
Use unique_ptr in cpdf_type3cache.h.
Change-Id: Iaea91df0300b55e35cbfd9b3f3389b3e291eae9b Reviewed-on: https://pdfium-review.googlesource.com/3618 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/render/cpdf_type3cache.cpp14
-rw-r--r--core/fpdfapi/render/cpdf_type3cache.h3
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_