summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-03-22 14:22:52 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-03-23 09:07:43 +0100
commit109420d42027cc9d614117226abd72a2e9b8cdce (patch)
tree47d2178074441bdd804cc4b963f4c0994d604e45
parent140192fd5a2fc5e9d250d077d00bcebc014f7cbf (diff)
use unique_ptr in AbstractTrueTypeFont
Change-Id: I57dcc1a247e01f1a31fcadc7f998833af42a0466 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112932 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--vcl/inc/sft.hxx4
-rw-r--r--vcl/source/fontsubset/sft.cxx6
2 files changed, 4 insertions, 6 deletions
diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 05b97dc8273b..877b94713a8f 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -720,7 +720,7 @@ constexpr int NUM_TAGS = 17;
class VCL_DLLPUBLIC AbstractTrueTypeFont
{
- char* m_pFileName;
+ std::unique_ptr<char[]> m_pFileName;
sal_uInt32 m_nGlyphs;
sal_uInt32 m_nHorzMetrics;
sal_uInt32 m_nVertMetrics; /* if not 0 => font has vertical metrics information */
@@ -735,7 +735,7 @@ public:
AbstractTrueTypeFont(const char* fileName = nullptr, const FontCharMapRef xCharMap = nullptr);
virtual ~AbstractTrueTypeFont();
- const char* fileName() const { return m_pFileName; }
+ const char* fileName() const { return m_pFileName.get(); }
sal_uInt32 glyphCount() const { return m_nGlyphs; }
sal_uInt32 glyphOffset(sal_uInt32 glyphID) const;
sal_uInt32 horzMetricCount() const { return m_nHorzMetrics; }
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index a08e475e4ebf..b4932164b98a 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -1114,20 +1114,18 @@ bool withinBounds(sal_uInt32 tdoffset, sal_uInt32 moreoffset, sal_uInt32 len, sa
}
AbstractTrueTypeFont::AbstractTrueTypeFont(const char* pFileName, const FontCharMapRef xCharMap)
- : m_pFileName(nullptr)
- , m_nGlyphs(0xFFFFFFFF)
+ : m_nGlyphs(0xFFFFFFFF)
, m_nHorzMetrics(0)
, m_nVertMetrics(0)
, m_nUnitsPerEm(0)
, m_xCharMap(xCharMap)
{
if (pFileName)
- m_pFileName = strdup(pFileName);
+ m_pFileName.reset(strdup(pFileName));
}
AbstractTrueTypeFont::~AbstractTrueTypeFont()
{
- free(m_pFileName);
}
TrueTypeFont::TrueTypeFont(const char* pFileName, const FontCharMapRef xCharMap)