hwpfilter/source/hfont.cxx | 13 ++++--------- hwpfilter/source/hfont.h | 3 ++- lingucomponent/source/spellcheck/spell/sspellimp.cxx | 9 +++------ lingucomponent/source/spellcheck/spell/sspellimp.hxx | 2 +- scaddins/source/analysis/analysis.cxx | 13 ++++--------- scaddins/source/analysis/analysis.hxx | 6 +++--- scaddins/source/pricing/pricing.cxx | 15 +++------------ scaddins/source/pricing/pricing.hxx | 5 +++-- 8 files changed, 23 insertions(+), 43 deletions(-)
New commits: commit 35ba29e093d41ce88a827ab145ba8df09ff0ee2f Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Feb 6 10:49:49 2018 +0200 loplugin:useuniqueptr in SpellChecker Change-Id: I36a9fe01e228f3f2f5e441c369291da4c461f735 Reviewed-on: https://gerrit.libreoffice.org/49874 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/lingucomponent/source/spellcheck/spell/sspellimp.cxx b/lingucomponent/source/spellcheck/spell/sspellimp.cxx index 12b9e240fa24..db6c183a8cef 100644 --- a/lingucomponent/source/spellcheck/spell/sspellimp.cxx +++ b/lingucomponent/source/spellcheck/spell/sspellimp.cxx @@ -72,7 +72,6 @@ using namespace linguistic; SpellChecker::SpellChecker() : m_aEvtListeners(GetLinguMutex()), - m_pPropHelper(nullptr), m_bDisposing(false) { } @@ -87,7 +86,6 @@ SpellChecker::~SpellChecker() if (m_pPropHelper) { m_pPropHelper->RemoveAsPropListener(); - delete m_pPropHelper; } } @@ -97,7 +95,7 @@ PropertyHelper_Spelling & SpellChecker::GetPropHelper_Impl() { Reference< XLinguProperties > xPropSet( GetLinguProperties(), UNO_QUERY ); - m_pPropHelper = new PropertyHelper_Spelling( static_cast<XSpellChecker *>(this), xPropSet ); + m_pPropHelper.reset( new PropertyHelper_Spelling( static_cast<XSpellChecker *>(this), xPropSet ) ); m_pPropHelper->AddAsPropListener(); //! after a reference is established } return *m_pPropHelper; @@ -577,7 +575,7 @@ void SAL_CALL SpellChecker::initialize( const Sequence< Any >& rArguments ) //! And the reference to the UNO-functions while increasing //! the ref-count and will implicitly free the memory //! when the object is no longer used. - m_pPropHelper = new PropertyHelper_Spelling( static_cast<XSpellChecker *>(this), xPropSet ); + m_pPropHelper.reset( new PropertyHelper_Spelling( static_cast<XSpellChecker *>(this), xPropSet ) ); m_pPropHelper->AddAsPropListener(); //! after a reference is established } else { @@ -598,8 +596,7 @@ void SAL_CALL SpellChecker::dispose() if (m_pPropHelper) { m_pPropHelper->RemoveAsPropListener(); - delete m_pPropHelper; - m_pPropHelper = nullptr; + m_pPropHelper.reset(); } } } diff --git a/lingucomponent/source/spellcheck/spell/sspellimp.hxx b/lingucomponent/source/spellcheck/spell/sspellimp.hxx index d8e5581463da..82ddbedf0af3 100644 --- a/lingucomponent/source/spellcheck/spell/sspellimp.hxx +++ b/lingucomponent/source/spellcheck/spell/sspellimp.hxx @@ -69,7 +69,7 @@ class SpellChecker : Sequence< Locale > m_aSuppLocales; ::comphelper::OInterfaceContainerHelper2 m_aEvtListeners; - linguistic::PropertyHelper_Spelling* m_pPropHelper; + std::unique_ptr<linguistic::PropertyHelper_Spelling> m_pPropHelper; bool m_bDisposing; SpellChecker(const SpellChecker &) = delete; commit cc85db4c4e2ca9ef8e1c9fc0af6d314767678faa Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Feb 6 10:42:23 2018 +0200 loplugin:useuniqueptr in scaddins Change-Id: I5c2c8301078d19824fb35966b158471ce6650c10 Reviewed-on: https://gerrit.libreoffice.org/49873 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/scaddins/source/analysis/analysis.cxx b/scaddins/source/analysis/analysis.cxx index 6c6a94afdb42..34414abd0f50 100644 --- a/scaddins/source/analysis/analysis.cxx +++ b/scaddins/source/analysis/analysis.cxx @@ -73,12 +73,10 @@ void AnalysisAddIn::InitData() { aResLocale = Translate::Create("sca", LanguageTag(aFuncLoc)); - delete pFD; - pFD = new FuncDataList; + pFD.reset(new FuncDataList); InitFuncDataList(*pFD); - delete pDefLocales; - pDefLocales = nullptr; + pDefLocales.reset(); } AnalysisAddIn::AnalysisAddIn( const uno::Reference< uno::XComponentContext >& xContext ) : @@ -92,9 +90,6 @@ AnalysisAddIn::AnalysisAddIn( const uno::Reference< uno::XComponentContext >& xC AnalysisAddIn::~AnalysisAddIn() { - delete pCDL; - delete pFD; - delete[] pDefLocales; } sal_Int32 AnalysisAddIn::getDateMode( @@ -337,7 +332,7 @@ static const sal_uInt32 nNumOfLoc = SAL_N_ELEMENTS(pLang); void AnalysisAddIn::InitDefLocales() { - pDefLocales = new lang::Locale[ nNumOfLoc ]; + pDefLocales.reset( new lang::Locale[ nNumOfLoc ] ); for( sal_uInt32 n = 0 ; n < nNumOfLoc ; n++ ) { @@ -1099,7 +1094,7 @@ OUString SAL_CALL AnalysisAddIn::getComplex( double fR, double fI, const uno::An double SAL_CALL AnalysisAddIn::getConvert( double f, const OUString& aFU, const OUString& aTU ) { if( !pCDL ) - pCDL = new ConvertDataList(); + pCDL.reset(new ConvertDataList()); double fRet = pCDL->Convert( f, aFU, aTU ); RETURN_FINITE( fRet ); diff --git a/scaddins/source/analysis/analysis.hxx b/scaddins/source/analysis/analysis.hxx index f187836d4a02..c90c265abc82 100644 --- a/scaddins/source/analysis/analysis.hxx +++ b/scaddins/source/analysis/analysis.hxx @@ -53,10 +53,10 @@ class AnalysisAddIn : public cppu::WeakImplHelper< { private: css::lang::Locale aFuncLoc; - css::lang::Locale* pDefLocales; - sca::analysis::FuncDataList* pFD; + std::unique_ptr<css::lang::Locale[]> pDefLocales; + std::unique_ptr<sca::analysis::FuncDataList> pFD; std::unique_ptr<double[]> pFactDoubles; - sca::analysis::ConvertDataList* pCDL; + std::unique_ptr<sca::analysis::ConvertDataList> pCDL; std::locale aResLocale; sca::analysis::ScaAnyConverter aAnyConv; diff --git a/scaddins/source/pricing/pricing.cxx b/scaddins/source/pricing/pricing.cxx index d60e4516cbf4..271e18ac80b0 100644 --- a/scaddins/source/pricing/pricing.cxx +++ b/scaddins/source/pricing/pricing.cxx @@ -133,8 +133,6 @@ ScaPricingAddIn::ScaPricingAddIn() : ScaPricingAddIn::~ScaPricingAddIn() { - delete pFuncDataList; - delete[] pDefLocales; } static const sal_Char* pLang[] = { "de", "en" }; @@ -143,7 +141,7 @@ static const sal_uInt32 nNumOfLoc = SAL_N_ELEMENTS( pLang ); void ScaPricingAddIn::InitDefLocales() { - pDefLocales = new lang::Locale[ nNumOfLoc ]; + pDefLocales.reset( new lang::Locale[ nNumOfLoc ] ); for( sal_uInt32 nIndex = 0; nIndex < nNumOfLoc; nIndex++ ) { @@ -163,16 +161,9 @@ const lang::Locale& ScaPricingAddIn::GetLocale( sal_uInt32 nIndex ) void ScaPricingAddIn::InitData() { aResLocale = Translate::Create("sca", LanguageTag(aFuncLoc)); - delete pFuncDataList; - - pFuncDataList = new ScaFuncDataList; + pFuncDataList.reset(new ScaFuncDataList); InitScaFuncDataList(*pFuncDataList); - - if( pDefLocales ) - { - delete pDefLocales; - pDefLocales = nullptr; - } + pDefLocales.reset(); } OUString ScaPricingAddIn::GetFuncDescrStr(const char** pResId, sal_uInt16 nStrIndex) diff --git a/scaddins/source/pricing/pricing.hxx b/scaddins/source/pricing/pricing.hxx index eb353e0a2235..6ee27108c2ba 100644 --- a/scaddins/source/pricing/pricing.hxx +++ b/scaddins/source/pricing/pricing.hxx @@ -30,6 +30,7 @@ #include <string.h> #include <vector> +#include <memory> #include <com/sun/star/lang/XServiceName.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -131,9 +132,9 @@ class ScaPricingAddIn : public ::cppu::WeakImplHelper< { private: css::lang::Locale aFuncLoc; - css::lang::Locale* pDefLocales; + std::unique_ptr<css::lang::Locale[]> pDefLocales; std::locale aResLocale; - sca::pricing::ScaFuncDataList* pFuncDataList; + std::unique_ptr<sca::pricing::ScaFuncDataList> pFuncDataList; void InitDefLocales(); commit 722d0b9882f20b7ae535c28fd1e2846756129376 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Feb 6 10:27:44 2018 +0200 loplugin:useuniqueptr in HWPFont Change-Id: Idd20e180fdd215028cf972e7ed97b37b7b9bed55 Reviewed-on: https://gerrit.libreoffice.org/49872 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> 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); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits