From 2489000d3fd66319a8355fd4e37cfdfda47296d0 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 Change-Id: I3a7a094da543debdcd2374737c2ecff91d644625 Reviewed-on: https://gerrit.libreoffice.org/33749 Tested-by: Jenkins Reviewed-by: Noel Grandin --- l10ntools/source/lngmerge.cxx | 7 +++---- l10ntools/source/propmerge.cxx | 6 ++---- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'l10ntools') diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx index a1de58d879f1..0411e1c6d201 100644 --- a/l10ntools/source/lngmerge.cxx +++ b/l10ntools/source/lngmerge.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "po.hxx" @@ -196,9 +197,9 @@ bool LngParser::Merge( OString sID( sGroup ); std::size_t nLastLangPos = 0; - ResData *pResData = new ResData( sID, sSource ); + std::unique_ptr pResData( new ResData( sID, sSource ) ); pResData->sResTyp = "LngText"; - MergeEntrys *pEntrys = aMergeDataFile.GetMergeEntrys( pResData ); + MergeEntrys *pEntrys = aMergeDataFile.GetMergeEntrys( pResData.get() ); // read languages bGroup = false; @@ -305,8 +306,6 @@ bool LngParser::Merge( } } } - - delete pResData; } for ( size_t i = 0; i < pLines->size(); ++i ) diff --git a/l10ntools/source/propmerge.cxx b/l10ntools/source/propmerge.cxx index e4e75f648f33..3a7c92b0aae4 100644 --- a/l10ntools/source/propmerge.cxx +++ b/l10ntools/source/propmerge.cxx @@ -166,10 +166,10 @@ void PropParser::Merge( const OString &rMergeSrc, const OString &rDestinationFil return; } - MergeDataFile* pMergeDataFile = nullptr; + std::unique_ptr pMergeDataFile; if( m_sLang != "qtz" ) { - pMergeDataFile = new MergeDataFile( rMergeSrc, m_sSource, false, false ); + pMergeDataFile.reset( new MergeDataFile( rMergeSrc, m_sSource, false, false ) ); const std::vector vLanguages = pMergeDataFile->GetLanguages(); if( vLanguages.size()>=1 && vLanguages[0] != m_sLang ) @@ -179,7 +179,6 @@ void PropParser::Merge( const OString &rMergeSrc, const OString &rDestinationFil " Mergedata file: ") << m_sLang.getStr() << " - " << vLanguages[0].getStr() << std::endl; - delete pMergeDataFile; return; } } @@ -225,7 +224,6 @@ void PropParser::Merge( const OString &rMergeSrc, const OString &rDestinationFil } } aDestination.close(); - delete pMergeDataFile; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit