summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-01-31 14:46:38 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-02-01 12:15:22 +0000
commit2489000d3fd66319a8355fd4e37cfdfda47296d0 (patch)
treecaad79e7b5bec3863604b20190b682c0d73d2b25 /scripting
parent595848c85acc2609fcc48a40c7a9f216a2722cd8 (diff)
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 Change-Id: I3a7a094da543debdcd2374737c2ecff91d644625 Reviewed-on: https://gerrit.libreoffice.org/33749 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'scripting')
-rw-r--r--scripting/source/stringresource/stringresource.cxx8
1 files changed, 2 insertions, 6 deletions
diff --git a/scripting/source/stringresource/stringresource.cxx b/scripting/source/stringresource/stringresource.cxx
index 190fabdde719..e21cf06a36c7 100644
--- a/scripting/source/stringresource/stringresource.cxx
+++ b/scripting/source/stringresource/stringresource.cxx
@@ -1511,7 +1511,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<sal_Int32[]> pPositions( new sal_Int32[nLocaleCount + 1] );
for( sal_Int32 i = 0; i < nLocaleCount + 1; i++ )
pPositions[i] = aIn.readInt32();
@@ -1542,8 +1542,6 @@ void StringResourcePersistenceImpl::importBinary( const Sequence< ::sal_Int8 >&
if( pUseAsDefaultItem != nullptr )
setDefaultLocale( pUseAsDefaultItem->m_locale );
-
- delete[] pPositions;
}
@@ -2106,7 +2104,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<const OUString*[]> 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 )
@@ -2132,8 +2130,6 @@ bool StringResourcePersistenceImpl::implWritePropertiesFile( LocaleItem* pLocale
}
}
}
-
- delete[] pIdPtrs;
}
bSuccess = true;