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:
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;
......
......@@ -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();
}
......
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