diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-26 11:37:45 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-29 18:22:33 +0200 |
commit | 2c1f77d34e5a660a72170e30986bd77d9b965ca1 (patch) | |
tree | ad39b7a16af44038af262fa7d747454b1f5a28d4 | |
parent | fcd589d4f304daadb9ddc5308c577e5a789c1293 (diff) |
loplugin:useuniqueptr in cclass_Unicode
Change-Id: Iecfff4104ef19f9bc6f83a403d99aecb2eda2514
Reviewed-on: https://gerrit.libreoffice.org/53607
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | i18npool/inc/cclass_unicode.hxx | 6 | ||||
-rw-r--r-- | i18npool/source/characterclassification/cclass_unicode_parser.cxx | 23 |
2 files changed, 12 insertions, 17 deletions
diff --git a/i18npool/inc/cclass_unicode.hxx b/i18npool/inc/cclass_unicode.hxx index 2b6e3d9e890f..d962a3216585 100644 --- a/i18npool/inc/cclass_unicode.hxx +++ b/i18npool/inc/cclass_unicode.hxx @@ -131,9 +131,9 @@ private: css::uno::Reference < css::i18n::XNativeNumberSupplier > xNatNumSup; OUString aStartChars; OUString aContChars; - ParserFlags* pTable; - ParserFlags* pStart; - ParserFlags* pCont; + std::unique_ptr<ParserFlags[]> pTable; + std::unique_ptr<ParserFlags[]> pStart; + std::unique_ptr<ParserFlags[]> pCont; sal_Int32 nStartTypes; sal_Int32 nContTypes; ScanState eState; diff --git a/i18npool/source/characterclassification/cclass_unicode_parser.cxx b/i18npool/source/characterclassification/cclass_unicode_parser.cxx index 981912b53c07..a5cb1b680984 100644 --- a/i18npool/source/characterclassification/cclass_unicode_parser.cxx +++ b/i18npool/source/characterclassification/cclass_unicode_parser.cxx @@ -410,18 +410,16 @@ void cclass_Unicode::initParserTable( const Locale& rLocale, sal_Int32 startChar setupInternational( rLocale ); // Memory of pTable is reused. if ( !pTable ) - pTable = new ParserFlags[nDefCnt]; - memcpy( pTable, pDefaultParserTable, sizeof(ParserFlags) * nDefCnt ); + pTable.reset(new ParserFlags[nDefCnt]); + memcpy( pTable.get(), pDefaultParserTable, sizeof(ParserFlags) * nDefCnt ); // Start and cont tables only need reallocation if different length. if ( pStart && userDefinedCharactersStart.getLength() != aStartChars.getLength() ) { - delete [] pStart; - pStart = nullptr; + pStart.reset(); } if ( pCont && userDefinedCharactersCont.getLength() != aContChars.getLength() ) { - delete [] pCont; - pCont = nullptr; + pCont.reset(); } nStartTypes = startCharTokenType; nContTypes = contCharTokenType; @@ -515,7 +513,7 @@ void cclass_Unicode::initParserTable( const Locale& rLocale, sal_Int32 startChar if ( nLen ) { if ( !pStart ) - pStart = new ParserFlags[ nLen ]; + pStart.reset(new ParserFlags[ nLen ]); const sal_Unicode* p = aStartChars.getStr(); for ( sal_Int32 j=0; j<nLen; j++, p++ ) { @@ -529,7 +527,7 @@ void cclass_Unicode::initParserTable( const Locale& rLocale, sal_Int32 startChar if ( nLen ) { if ( !pCont ) - pCont = new ParserFlags[ nLen ]; + pCont.reset(new ParserFlags[ nLen ]); const sal_Unicode* p = aContChars.getStr(); for ( sal_Int32 j=0; j<nLen; j++ ) { @@ -543,12 +541,9 @@ void cclass_Unicode::initParserTable( const Locale& rLocale, sal_Int32 startChar void cclass_Unicode::destroyParserTable() { - if ( pCont ) - delete [] pCont; - if ( pStart ) - delete [] pStart; - if ( pTable ) - delete [] pTable; + pCont.reset(); + pStart.reset(); + pTable.reset(); } |