diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-06 10:27:44 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-17 07:06:36 +0100 |
commit | 722d0b9882f20b7ae535c28fd1e2846756129376 (patch) | |
tree | fbc4b93e7ee8e8276d7d02ef264de63ddd08e8bf /hwpfilter | |
parent | 7a510effa4566d405d2033b6635b42c08d34dec8 (diff) |
loplugin:useuniqueptr in HWPFont
Change-Id: Idd20e180fdd215028cf972e7ed97b37b7b9bed55
Reviewed-on: https://gerrit.libreoffice.org/49872
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'hwpfilter')
-rw-r--r-- | hwpfilter/source/hfont.cxx | 13 | ||||
-rw-r--r-- | hwpfilter/source/hfont.h | 3 |
2 files changed, 6 insertions, 10 deletions
diff --git a/hwpfilter/source/hfont.cxx b/hwpfilter/source/hfont.cxx index 70e394282abc..e5c23a88199b 100644 --- a/hwpfilter/source/hfont.cxx +++ b/hwpfilter/source/hfont.cxx @@ -35,11 +35,6 @@ HWPFont::HWPFont() HWPFont::~HWPFont() { - for (int ii = 0; ii < NLanguage; ii++) - { - nFonts[ii] = 0; - delete[]fontnames[ii]; - } } @@ -52,7 +47,7 @@ void HWPFont::AddFont(int lang, const char *font) nfonts = nFonts[lang]; if (MAXFONTS <= nfonts) return; - strncpy(fontnames[lang] + FONTNAMELEN * nfonts, font, FONTNAMELEN - 1); + strncpy(fontnames[lang].get() + FONTNAMELEN * nfonts, font, FONTNAMELEN - 1); nFonts[lang]++; } @@ -63,7 +58,7 @@ const char *HWPFont::GetFontName(int lang, int id) return nullptr; if (id < 0 || nFonts[lang] <= id) return nullptr; - return fontnames[lang] + id * FONTNAMELEN; + return fontnames[lang].get() + id * FONTNAMELEN; } @@ -83,9 +78,9 @@ void HWPFont::Read(HWPFile & hwpf) (void)hwpf.SetState(HWP_InvalidFileFormat); return; } - fontnames[lang] = new char[nfonts * FONTNAMELEN]; + fontnames[lang].reset(new char[nfonts * FONTNAMELEN]); - memset(fontnames[lang], 0, nfonts * FONTNAMELEN); + memset(fontnames[lang].get(), 0, nfonts * FONTNAMELEN); for (int jj = 0; jj < nfonts; jj++) { hwpf.ReadBlock(buffer, FONTNAMELEN); diff --git a/hwpfilter/source/hfont.h b/hwpfilter/source/hfont.h index f70d2de82c73..c9d2e9930ec8 100644 --- a/hwpfilter/source/hfont.h +++ b/hwpfilter/source/hfont.h @@ -22,6 +22,7 @@ #include <stdlib.h> #include <string.h> +#include <memory> #define MAXFONTS 256 #define FONTNAMELEN 40 @@ -42,7 +43,7 @@ class DLLEXPORT HWPFont final /** * list of the font family name */ - char *fontnames[NLanguage]; + std::unique_ptr<char[]> fontnames[NLanguage]; public: HWPFont(void); |