summaryrefslogtreecommitdiff
path: root/l10ntools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-01-31 14:46:38 +0200
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2017-12-05 08:17:11 -0500
commit9ca19666511b1d44ba554a70cbbc0c8e2db844c6 (patch)
tree39a0bd694d2f1cf5d5a67082b85717e5bb2cbef0 /l10ntools
parent6346e8c08e789e6aa4f2041fab97ba14419dedd4 (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 Reviewed-on: https://gerrit.libreoffice.org/33749 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> (cherry picked from commit 2489000d3fd66319a8355fd4e37cfdfda47296d0) Change-Id: I3a7a094da543debdcd2374737c2ecff91d644625 (cherry picked from commit e540ccfb5eb43bd4a3d6920074dce8436720ba8e)
Diffstat (limited to 'l10ntools')
-rw-r--r--l10ntools/source/lngmerge.cxx7
-rw-r--r--l10ntools/source/propmerge.cxx6
2 files changed, 5 insertions, 8 deletions
diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx
index 1d33c929278a..41328ae421e7 100644
--- a/l10ntools/source/lngmerge.cxx
+++ b/l10ntools/source/lngmerge.cxx
@@ -22,6 +22,7 @@
#include <cstddef>
#include <fstream>
#include <iterator>
+#include <memory>
#include <string>
#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<ResData> 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 78680e844165..bb479cd2b997 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<MergeDataFile> 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<OString> 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: */