From 9b671ace8aec906683b05399cf8a2882ed8ef7b6 Mon Sep 17 00:00:00 2001 From: weili Date: Mon, 25 Jul 2016 07:40:27 -0700 Subject: Use smart pointers for CFX_Font and CFX_Type3Font classes For the class owned member variables, use std::unique_ptr or std::vector for memory management. BUG=pdfium:518 Review-Url: https://codereview.chromium.org/2169793002 --- core/fxge/include/fx_font.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'core/fxge/include') diff --git a/core/fxge/include/fx_font.h b/core/fxge/include/fx_font.h index 8c9bdb92c4..9b43f16710 100644 --- a/core/fxge/include/fx_font.h +++ b/core/fxge/include/fx_font.h @@ -86,7 +86,7 @@ class CFX_Font { FX_BOOL LoadEmbedded(const uint8_t* data, uint32_t size); FXFT_Face GetFace() const { return m_Face; } - CFX_SubstFont* GetSubstFont() const { return m_pSubstFont; } + CFX_SubstFont* GetSubstFont() const { return m_pSubstFont.get(); } #ifdef PDF_ENABLE_XFA FX_BOOL LoadFile(IFX_FileRead* pFile, @@ -95,7 +95,9 @@ class CFX_Font { FX_BOOL LoadClone(const CFX_Font* pFont); void SetFace(FXFT_Face face) { m_Face = face; } - void SetSubstFont(CFX_SubstFont* subst) { m_pSubstFont = subst; } + void SetSubstFont(std::unique_ptr subst) { + m_pSubstFont = std::move(subst); + } #endif // PDF_ENABLE_XFA CFX_PathData* LoadGlyphPath(uint32_t glyph_index, int dest_width = 0); @@ -139,8 +141,8 @@ class CFX_Font { void DeleteFace(); FXFT_Face m_Face; - CFX_SubstFont* m_pSubstFont; - uint8_t* m_pFontDataAllocation; + std::unique_ptr m_pSubstFont; + std::vector m_pFontDataAllocation; uint8_t* m_pFontData; uint8_t* m_pGsubData; uint32_t m_dwSize; @@ -501,6 +503,7 @@ class CFX_AutoFontCache { CFX_FontCache* m_pFontCache; CFX_Font* m_pFont; }; + #define FX_FONTCACHE_DEFINE(pFontCache, pFont) \ CFX_AutoFontCache autoFontCache((pFontCache), (pFont)) class CFX_GlyphBitmap { @@ -509,6 +512,7 @@ class CFX_GlyphBitmap { int m_Left; CFX_DIBitmap m_Bitmap; }; + class CFX_FaceCache { public: explicit CFX_FaceCache(FXFT_Face face); -- cgit v1.2.3