Kaydet (Commit) 2c1f77d3 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in cclass_Unicode

Change-Id: Iecfff4104ef19f9bc6f83a403d99aecb2eda2514
Reviewed-on: https://gerrit.libreoffice.org/53607Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst fcd589d4
...@@ -131,9 +131,9 @@ private: ...@@ -131,9 +131,9 @@ private:
css::uno::Reference < css::i18n::XNativeNumberSupplier > xNatNumSup; css::uno::Reference < css::i18n::XNativeNumberSupplier > xNatNumSup;
OUString aStartChars; OUString aStartChars;
OUString aContChars; OUString aContChars;
ParserFlags* pTable; std::unique_ptr<ParserFlags[]> pTable;
ParserFlags* pStart; std::unique_ptr<ParserFlags[]> pStart;
ParserFlags* pCont; std::unique_ptr<ParserFlags[]> pCont;
sal_Int32 nStartTypes; sal_Int32 nStartTypes;
sal_Int32 nContTypes; sal_Int32 nContTypes;
ScanState eState; ScanState eState;
......
...@@ -410,18 +410,16 @@ void cclass_Unicode::initParserTable( const Locale& rLocale, sal_Int32 startChar ...@@ -410,18 +410,16 @@ void cclass_Unicode::initParserTable( const Locale& rLocale, sal_Int32 startChar
setupInternational( rLocale ); setupInternational( rLocale );
// Memory of pTable is reused. // Memory of pTable is reused.
if ( !pTable ) if ( !pTable )
pTable = new ParserFlags[nDefCnt]; pTable.reset(new ParserFlags[nDefCnt]);
memcpy( pTable, pDefaultParserTable, sizeof(ParserFlags) * nDefCnt ); memcpy( pTable.get(), pDefaultParserTable, sizeof(ParserFlags) * nDefCnt );
// Start and cont tables only need reallocation if different length. // Start and cont tables only need reallocation if different length.
if ( pStart && userDefinedCharactersStart.getLength() != aStartChars.getLength() ) if ( pStart && userDefinedCharactersStart.getLength() != aStartChars.getLength() )
{ {
delete [] pStart; pStart.reset();
pStart = nullptr;
} }
if ( pCont && userDefinedCharactersCont.getLength() != aContChars.getLength() ) if ( pCont && userDefinedCharactersCont.getLength() != aContChars.getLength() )
{ {
delete [] pCont; pCont.reset();
pCont = nullptr;
} }
nStartTypes = startCharTokenType; nStartTypes = startCharTokenType;
nContTypes = contCharTokenType; nContTypes = contCharTokenType;
...@@ -515,7 +513,7 @@ void cclass_Unicode::initParserTable( const Locale& rLocale, sal_Int32 startChar ...@@ -515,7 +513,7 @@ void cclass_Unicode::initParserTable( const Locale& rLocale, sal_Int32 startChar
if ( nLen ) if ( nLen )
{ {
if ( !pStart ) if ( !pStart )
pStart = new ParserFlags[ nLen ]; pStart.reset(new ParserFlags[ nLen ]);
const sal_Unicode* p = aStartChars.getStr(); const sal_Unicode* p = aStartChars.getStr();
for ( sal_Int32 j=0; j<nLen; j++, p++ ) for ( sal_Int32 j=0; j<nLen; j++, p++ )
{ {
...@@ -529,7 +527,7 @@ void cclass_Unicode::initParserTable( const Locale& rLocale, sal_Int32 startChar ...@@ -529,7 +527,7 @@ void cclass_Unicode::initParserTable( const Locale& rLocale, sal_Int32 startChar
if ( nLen ) if ( nLen )
{ {
if ( !pCont ) if ( !pCont )
pCont = new ParserFlags[ nLen ]; pCont.reset(new ParserFlags[ nLen ]);
const sal_Unicode* p = aContChars.getStr(); const sal_Unicode* p = aContChars.getStr();
for ( sal_Int32 j=0; j<nLen; j++ ) for ( sal_Int32 j=0; j<nLen; j++ )
{ {
...@@ -543,12 +541,9 @@ void cclass_Unicode::initParserTable( const Locale& rLocale, sal_Int32 startChar ...@@ -543,12 +541,9 @@ void cclass_Unicode::initParserTable( const Locale& rLocale, sal_Int32 startChar
void cclass_Unicode::destroyParserTable() void cclass_Unicode::destroyParserTable()
{ {
if ( pCont ) pCont.reset();
delete [] pCont; pStart.reset();
if ( pStart ) pTable.reset();
delete [] pStart;
if ( pTable )
delete [] pTable;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment