summaryrefslogtreecommitdiff
path: root/l10ntools
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 /l10ntools
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 '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 a1de58d879f1..0411e1c6d201 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 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<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: */