[Libreoffice-commits] core.git: vcl/inc vcl/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Tue Mar 23 08:08:27 UTC 2021


 vcl/inc/sft.hxx               |    4 ++--
 vcl/source/fontsubset/sft.cxx |    6 ++----
 2 files changed, 4 insertions(+), 6 deletions(-)

New commits:
commit 109420d42027cc9d614117226abd72a2e9b8cdce
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Mon Mar 22 14:22:52 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Mar 23 09:07:43 2021 +0100

    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 at collabora.co.uk>

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)


More information about the Libreoffice-commits mailing list