From 9ca19666511b1d44ba554a70cbbc0c8e2db844c6 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 31 Jan 2017 14:46:38 +0200 Subject: loplugin:useuniqueptr extend to check local vars just the simple and obvious case for now, of a local var being allocated and deleted inside a single local block, and the delete happening at the end of the block Reviewed-on: https://gerrit.libreoffice.org/33749 Tested-by: Jenkins Reviewed-by: Noel Grandin (cherry picked from commit 2489000d3fd66319a8355fd4e37cfdfda47296d0) Change-Id: I3a7a094da543debdcd2374737c2ecff91d644625 (cherry picked from commit e540ccfb5eb43bd4a3d6920074dce8436720ba8e) --- scripting/source/stringresource/stringresource.cxx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'scripting') diff --git a/scripting/source/stringresource/stringresource.cxx b/scripting/source/stringresource/stringresource.cxx index f29dbfbf56f4..dcbf0dffa839 100644 --- a/scripting/source/stringresource/stringresource.cxx +++ b/scripting/source/stringresource/stringresource.cxx @@ -1571,7 +1571,7 @@ void StringResourcePersistenceImpl::importBinary( const Sequence< ::sal_Int8 >& sal_Int32 iDefault = aIn.readInt16(); (void)iDefault; - sal_Int32* pPositions = new sal_Int32[nLocaleCount + 1]; + std::unique_ptr pPositions( new sal_Int32[nLocaleCount + 1] ); for( sal_Int32 i = 0; i < nLocaleCount + 1; i++ ) pPositions[i] = aIn.readInt32(); @@ -1602,8 +1602,6 @@ void StringResourcePersistenceImpl::importBinary( const Sequence< ::sal_Int8 >& if( pUseAsDefaultItem != nullptr ) setDefaultLocale( pUseAsDefaultItem->m_locale ); - - delete[] pPositions; } @@ -2166,7 +2164,7 @@ bool StringResourcePersistenceImpl::implWritePropertiesFile( LocaleItem* pLocale sal_Int32 nTabSize = nMaxIndex - nMinIndex + 1; // Create sorted array of pointers to the id strings - const OUString** pIdPtrs = new const OUString*[nTabSize]; + std::unique_ptr pIdPtrs( new const OUString*[nTabSize] ); for(sal_Int32 i = 0 ; i < nTabSize ; i++ ) pIdPtrs[i] = nullptr; for( it_index = rIndexMap.begin(); it_index != rIndexMap.end(); ++it_index ) @@ -2192,8 +2190,6 @@ bool StringResourcePersistenceImpl::implWritePropertiesFile( LocaleItem* pLocale } } } - - delete[] pIdPtrs; } bSuccess = true; -- cgit