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

loplugin:useuniqueptr in i18npool

Change-Id: I57c6ce2a8c48bc87404e596b8843efd67ea0872d
Reviewed-on: https://gerrit.libreoffice.org/65033
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst c908f61d
...@@ -145,7 +145,7 @@ void BreakIterator_Unicode::loadICUBreakIterator(const css::lang::Locale& rLocal ...@@ -145,7 +145,7 @@ void BreakIterator_Unicode::loadICUBreakIterator(const css::lang::Locale& rLocal
udata_setAppData("OpenOffice", OpenOffice_dat, &status); udata_setAppData("OpenOffice", OpenOffice_dat, &status);
if ( !U_SUCCESS(status) ) throw uno::RuntimeException(); if ( !U_SUCCESS(status) ) throw uno::RuntimeException();
OOoRuleBasedBreakIterator *rbi = nullptr; std::unique_ptr<OOoRuleBasedBreakIterator> rbi;
if (breakRules.getLength() > breakType && !breakRules[breakType].isEmpty()) if (breakRules.getLength() > breakType && !breakRules[breakType].isEmpty())
{ {
...@@ -161,19 +161,18 @@ void BreakIterator_Unicode::loadICUBreakIterator(const css::lang::Locale& rLocal ...@@ -161,19 +161,18 @@ void BreakIterator_Unicode::loadICUBreakIterator(const css::lang::Locale& rLocal
break; // do break; // do
} }
rbi = new OOoRuleBasedBreakIterator(udata_open("OpenOffice", "brk", rbi.reset(new OOoRuleBasedBreakIterator(udata_open("OpenOffice", "brk",
OUStringToOString(breakRules[breakType], RTL_TEXTENCODING_ASCII_US).getStr(), &status), status); OUStringToOString(breakRules[breakType], RTL_TEXTENCODING_ASCII_US).getStr(), &status), status));
if (U_SUCCESS(status)) if (U_SUCCESS(status))
{ {
icuBI->mpValue.reset( new BI_ValueData); icuBI->mpValue.reset( new BI_ValueData);
icuBI->mpValue->mpBreakIterator.reset( rbi); icuBI->mpValue->mpBreakIterator = std::move( rbi);
theBIMap.insert( std::make_pair( aBIMapRuleTypeKey, icuBI->mpValue)); theBIMap.insert( std::make_pair( aBIMapRuleTypeKey, icuBI->mpValue));
} }
else else
{ {
delete rbi; rbi.reset();
rbi = nullptr;
} }
} }
//use icu's breakiterator for Thai, Tibetan and Dzongkha //use icu's breakiterator for Thai, Tibetan and Dzongkha
...@@ -199,17 +198,16 @@ void BreakIterator_Unicode::loadICUBreakIterator(const css::lang::Locale& rLocal ...@@ -199,17 +198,16 @@ void BreakIterator_Unicode::loadICUBreakIterator(const css::lang::Locale& rLocal
aUDName.append( aLanguage); aUDName.append( aLanguage);
UDataMemory* pUData = udata_open("OpenOffice", "brk", aUDName.getStr(), &status); UDataMemory* pUData = udata_open("OpenOffice", "brk", aUDName.getStr(), &status);
if( U_SUCCESS(status) ) if( U_SUCCESS(status) )
rbi = new OOoRuleBasedBreakIterator( pUData, status); rbi.reset(new OOoRuleBasedBreakIterator( pUData, status));
if ( U_SUCCESS(status) ) if ( U_SUCCESS(status) )
{ {
icuBI->mpValue.reset( new BI_ValueData); icuBI->mpValue.reset( new BI_ValueData);
icuBI->mpValue->mpBreakIterator.reset( rbi); icuBI->mpValue->mpBreakIterator = std::move( rbi);
theBIMap.insert( std::make_pair( aBIMapRuleKey, icuBI->mpValue)); theBIMap.insert( std::make_pair( aBIMapRuleKey, icuBI->mpValue));
} }
else else
{ {
delete rbi; rbi.reset();
rbi = nullptr;
// ;rule (only) // ;rule (only)
const OString aBIMapRuleOnlyKey( OString(";") + rule); const OString aBIMapRuleOnlyKey( OString(";") + rule);
...@@ -226,17 +224,16 @@ void BreakIterator_Unicode::loadICUBreakIterator(const css::lang::Locale& rLocal ...@@ -226,17 +224,16 @@ void BreakIterator_Unicode::loadICUBreakIterator(const css::lang::Locale& rLocal
status = U_ZERO_ERROR; status = U_ZERO_ERROR;
pUData = udata_open("OpenOffice", "brk", rule, &status); pUData = udata_open("OpenOffice", "brk", rule, &status);
if( U_SUCCESS(status) ) if( U_SUCCESS(status) )
rbi = new OOoRuleBasedBreakIterator( pUData, status); rbi.reset(new OOoRuleBasedBreakIterator( pUData, status));
if ( U_SUCCESS(status) ) if ( U_SUCCESS(status) )
{ {
icuBI->mpValue.reset( new BI_ValueData); icuBI->mpValue.reset( new BI_ValueData);
icuBI->mpValue->mpBreakIterator.reset( rbi); icuBI->mpValue->mpBreakIterator = std::move( rbi);
theBIMap.insert( std::make_pair( aBIMapRuleOnlyKey, icuBI->mpValue)); theBIMap.insert( std::make_pair( aBIMapRuleOnlyKey, icuBI->mpValue));
} }
else else
{ {
delete rbi; rbi.reset();
rbi = nullptr;
} }
} }
} }
......
...@@ -561,16 +561,17 @@ oslGenericFunction lcl_LookupTableHelper::getFunctionSymbolByName( ...@@ -561,16 +561,17 @@ oslGenericFunction lcl_LookupTableHelper::getFunctionSymbolByName(
aBuf.ensureCapacity(strlen(i.pLib) + 4); // mostly "*.dll" aBuf.ensureCapacity(strlen(i.pLib) + 4); // mostly "*.dll"
aBuf.appendAscii(i.pLib).append( SAL_DLLEXTENSION ); aBuf.appendAscii(i.pLib).append( SAL_DLLEXTENSION );
#endif #endif
osl::Module *module = new osl::Module(); std::unique_ptr<osl::Module> module(new osl::Module());
if ( module->loadRelative(&thisModule, aBuf.makeStringAndClear()) ) if ( module->loadRelative(&thisModule, aBuf.makeStringAndClear()) )
{ {
::osl::MutexGuard aGuard( maMutex ); ::osl::MutexGuard aGuard( maMutex );
maLookupTable.emplace_back(i.pLib, module, i.pLocale); auto pTmpModule = module.get();
maLookupTable.emplace_back(i.pLib, module.release(), i.pLocale);
OSL_ASSERT( pOutCachedItem ); OSL_ASSERT( pOutCachedItem );
if( pOutCachedItem ) if( pOutCachedItem )
{ {
pOutCachedItem->reset(new LocaleDataLookupTableItem( maLookupTable.back() )); pOutCachedItem->reset(new LocaleDataLookupTableItem( maLookupTable.back() ));
return module->getFunctionSymbol( return pTmpModule->getFunctionSymbol(
aBuf.appendAscii(pFunction).append(cUnder). aBuf.appendAscii(pFunction).append(cUnder).
appendAscii((*pOutCachedItem)->localeName).makeStringAndClear()); appendAscii((*pOutCachedItem)->localeName).makeStringAndClear());
} }
...@@ -578,7 +579,7 @@ oslGenericFunction lcl_LookupTableHelper::getFunctionSymbolByName( ...@@ -578,7 +579,7 @@ oslGenericFunction lcl_LookupTableHelper::getFunctionSymbolByName(
return nullptr; return nullptr;
} }
else else
delete module; module.reset();
#else #else
(void) pOutCachedItem; (void) pOutCachedItem;
......
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