Kaydet (Commit) 7924a77e authored tarafından Matteo Casalin's avatar Matteo Casalin Kaydeden (comit) Caolán McNamara

Fix memory leaks

Change-Id: I21662cb52c51332700e1021ae55d92cb46ccc15a
Reviewed-on: https://gerrit.libreoffice.org/6029Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 1ebe1d6d
...@@ -21,7 +21,7 @@ static void checkStyleNames(OString aLanguage) ...@@ -21,7 +21,7 @@ static void checkStyleNames(OString aLanguage)
{ {
std::map<OString,sal_uInt16> aLocalizedStyleNames; std::map<OString,sal_uInt16> aLocalizedStyleNames;
std::map<OString,sal_uInt16> aLocalizedNumStyleNames; std::map<OString,sal_uInt16> aLocalizedNumStyleNames;
std::list<PoEntry*> repeatedEntries; std::list<PoEntry> repeatedEntries;
OString aPoPath = OString(getenv("SRC_ROOT")) + OString aPoPath = OString(getenv("SRC_ROOT")) +
"/translations/source/" + "/translations/source/" +
...@@ -33,19 +33,18 @@ static void checkStyleNames(OString aLanguage) ...@@ -33,19 +33,18 @@ static void checkStyleNames(OString aLanguage)
for(;;) for(;;)
{ {
PoEntry* pPoEntry = new PoEntry(); PoEntry aPoEntry;
aPoInput.readEntry(*pPoEntry); aPoInput.readEntry(aPoEntry);
bool bRepeated = false; bool bRepeated = false;
if( aPoInput.eof() ) if( aPoInput.eof() )
{ {
delete pPoEntry;
break; break;
} }
if( !pPoEntry->isFuzzy() && pPoEntry->getSourceFile() == "poolfmt.src" && if( !aPoEntry.isFuzzy() && aPoEntry.getSourceFile() == "poolfmt.src" &&
pPoEntry->getGroupId().startsWith("STR_POOLCOLL") ) aPoEntry.getGroupId().startsWith("STR_POOLCOLL") )
{ {
OString aMsgStr = pPoEntry->getMsgStr(); OString aMsgStr = aPoEntry.getMsgStr();
if( aMsgStr.isEmpty() ) if( aMsgStr.isEmpty() )
continue; continue;
if( aLocalizedStyleNames.find(aMsgStr) == aLocalizedStyleNames.end() ) if( aLocalizedStyleNames.find(aMsgStr) == aLocalizedStyleNames.end() )
...@@ -55,10 +54,10 @@ static void checkStyleNames(OString aLanguage) ...@@ -55,10 +54,10 @@ static void checkStyleNames(OString aLanguage)
bRepeated = true; bRepeated = true;
} }
} }
if( !pPoEntry->isFuzzy() && pPoEntry->getSourceFile() == "poolfmt.src" && if( !aPoEntry.isFuzzy() && aPoEntry.getSourceFile() == "poolfmt.src" &&
pPoEntry->getGroupId().startsWith("STR_POOLNUMRULE") ) aPoEntry.getGroupId().startsWith("STR_POOLNUMRULE") )
{ {
OString aMsgStr = pPoEntry->getMsgStr(); OString aMsgStr = aPoEntry.getMsgStr();
if( aMsgStr.isEmpty() ) if( aMsgStr.isEmpty() )
continue; continue;
if( aLocalizedNumStyleNames.find(aMsgStr) == aLocalizedNumStyleNames.end() ) if( aLocalizedNumStyleNames.find(aMsgStr) == aLocalizedNumStyleNames.end() )
...@@ -69,10 +68,7 @@ static void checkStyleNames(OString aLanguage) ...@@ -69,10 +68,7 @@ static void checkStyleNames(OString aLanguage)
} }
} }
if (bRepeated) if (bRepeated)
repeatedEntries.push_back(pPoEntry); repeatedEntries.push_back(aPoEntry);
else
delete pPoEntry;
} }
aPoInput.close(); aPoInput.close();
...@@ -110,8 +106,8 @@ static void checkStyleNames(OString aLanguage) ...@@ -110,8 +106,8 @@ static void checkStyleNames(OString aLanguage)
aPoInput.readEntry(aPoEntry); aPoInput.readEntry(aPoEntry);
if( aPoInput.eof() ) if( aPoInput.eof() )
break; break;
for ( std::list<PoEntry*>::iterator it=repeatedEntries.begin(); it!=repeatedEntries.end(); ++it) { for ( std::list<PoEntry>::iterator it=repeatedEntries.begin(); it!=repeatedEntries.end(); ++it) {
if ((*it)->getMsgId() == aPoEntry.getMsgId() && (*it)->getGroupId() == aPoEntry.getGroupId()) { if (it->getMsgId() == aPoEntry.getMsgId() && it->getGroupId() == aPoEntry.getGroupId()) {
bError = true; bError = true;
break; break;
} }
...@@ -139,7 +135,7 @@ static void checkFunctionNames(OString aLanguage) ...@@ -139,7 +135,7 @@ static void checkFunctionNames(OString aLanguage)
std::map<OString,sal_uInt16> aLocalizedFunctionNames; std::map<OString,sal_uInt16> aLocalizedFunctionNames;
std::map<OString,sal_uInt16> aLocalizedCoreFunctionNames; std::map<OString,sal_uInt16> aLocalizedCoreFunctionNames;
// //
std::list<PoEntry*> repeatedEntries; std::list<PoEntry> repeatedEntries;
OString aPoPaths[4]; OString aPoPaths[4];
OUString aPoPathURL; OUString aPoPathURL;
...@@ -155,20 +151,19 @@ static void checkFunctionNames(OString aLanguage) ...@@ -155,20 +151,19 @@ static void checkFunctionNames(OString aLanguage)
for(;;) for(;;)
{ {
PoEntry* aPoEntry = new PoEntry(); PoEntry aPoEntry;
aPoInput.readEntry(*aPoEntry); aPoInput.readEntry(aPoEntry);
if( aPoInput.eof() ) if( aPoInput.eof() )
break; break;
if( !aPoEntry->isFuzzy() && aPoEntry->getGroupId() == "RID_STRLIST_FUNCTION_NAMES" ) if( !aPoEntry.isFuzzy() && aPoEntry.getGroupId() == "RID_STRLIST_FUNCTION_NAMES" )
{ {
OString aMsgStr = aPoEntry->getMsgStr(); OString aMsgStr = aPoEntry.getMsgStr();
if( aMsgStr.isEmpty() ) if( aMsgStr.isEmpty() )
continue; continue;
if( aLocalizedCoreFunctionNames.find(aMsgStr) == aLocalizedCoreFunctionNames.end() ) if( aLocalizedCoreFunctionNames.find(aMsgStr) == aLocalizedCoreFunctionNames.end() )
aLocalizedCoreFunctionNames[aMsgStr] = 1; aLocalizedCoreFunctionNames[aMsgStr] = 1;
if( aLocalizedFunctionNames.find(aMsgStr) == aLocalizedFunctionNames.end() ) { if( aLocalizedFunctionNames.find(aMsgStr) == aLocalizedFunctionNames.end() ) {
aLocalizedFunctionNames[aMsgStr] = 1; aLocalizedFunctionNames[aMsgStr] = 1;
delete aPoEntry;
} else { } else {
aLocalizedFunctionNames[aMsgStr]++; aLocalizedFunctionNames[aMsgStr]++;
repeatedEntries.push_back(aPoEntry); repeatedEntries.push_back(aPoEntry);
...@@ -187,20 +182,19 @@ static void checkFunctionNames(OString aLanguage) ...@@ -187,20 +182,19 @@ static void checkFunctionNames(OString aLanguage)
for(;;) for(;;)
{ {
PoEntry* aPoEntry = new PoEntry(); PoEntry aPoEntry;
aPoInput.readEntry(*aPoEntry); aPoInput.readEntry(aPoEntry);
if( aPoInput.eof() ) if( aPoInput.eof() )
break; break;
if( !aPoEntry->isFuzzy() && aPoEntry->getGroupId() == "RID_ANALYSIS_FUNCTION_NAMES" ) if( !aPoEntry.isFuzzy() && aPoEntry.getGroupId() == "RID_ANALYSIS_FUNCTION_NAMES" )
{ {
OString aMsgStr = aPoEntry->getMsgStr(); OString aMsgStr = aPoEntry.getMsgStr();
if( aMsgStr.isEmpty() ) if( aMsgStr.isEmpty() )
continue; continue;
if( aLocalizedCoreFunctionNames.find(aMsgStr) != aLocalizedCoreFunctionNames.end() ) if( aLocalizedCoreFunctionNames.find(aMsgStr) != aLocalizedCoreFunctionNames.end() )
aMsgStr += "_ADD"; aMsgStr += "_ADD";
if( aLocalizedFunctionNames.find(aMsgStr) == aLocalizedFunctionNames.end() ) { if( aLocalizedFunctionNames.find(aMsgStr) == aLocalizedFunctionNames.end() ) {
aLocalizedFunctionNames[aMsgStr] = 1; aLocalizedFunctionNames[aMsgStr] = 1;
delete aPoEntry;
} else { } else {
aLocalizedFunctionNames[aMsgStr]++; aLocalizedFunctionNames[aMsgStr]++;
repeatedEntries.push_back(aPoEntry); repeatedEntries.push_back(aPoEntry);
...@@ -220,20 +214,19 @@ static void checkFunctionNames(OString aLanguage) ...@@ -220,20 +214,19 @@ static void checkFunctionNames(OString aLanguage)
for(;;) for(;;)
{ {
PoEntry* aPoEntry = new PoEntry(); PoEntry aPoEntry;
aPoInput.readEntry(*aPoEntry); aPoInput.readEntry(aPoEntry);
if( aPoInput.eof() ) if( aPoInput.eof() )
break; break;
if( !aPoEntry->isFuzzy() && aPoEntry->getGroupId() == "RID_DATE_FUNCTION_NAMES" ) if( !aPoEntry.isFuzzy() && aPoEntry.getGroupId() == "RID_DATE_FUNCTION_NAMES" )
{ {
OString aMsgStr = aPoEntry->getMsgStr(); OString aMsgStr = aPoEntry.getMsgStr();
if( aMsgStr.isEmpty() ) if( aMsgStr.isEmpty() )
continue; continue;
if( aLocalizedCoreFunctionNames.find(aMsgStr) != aLocalizedCoreFunctionNames.end() ) if( aLocalizedCoreFunctionNames.find(aMsgStr) != aLocalizedCoreFunctionNames.end() )
aMsgStr += "_ADD"; aMsgStr += "_ADD";
if( aLocalizedFunctionNames.find(aMsgStr) == aLocalizedFunctionNames.end() ) { if( aLocalizedFunctionNames.find(aMsgStr) == aLocalizedFunctionNames.end() ) {
aLocalizedFunctionNames[aMsgStr] = 1; aLocalizedFunctionNames[aMsgStr] = 1;
delete aPoEntry;
} else { } else {
aLocalizedFunctionNames[aMsgStr]++; aLocalizedFunctionNames[aMsgStr]++;
repeatedEntries.push_back(aPoEntry); repeatedEntries.push_back(aPoEntry);
...@@ -252,27 +245,25 @@ static void checkFunctionNames(OString aLanguage) ...@@ -252,27 +245,25 @@ static void checkFunctionNames(OString aLanguage)
for(;;) for(;;)
{ {
PoEntry* pPoEntry = new PoEntry(); PoEntry aPoEntry;
aPoInput.readEntry(*pPoEntry); aPoInput.readEntry(aPoEntry);
if( aPoInput.eof() ) if( aPoInput.eof() )
{ {
delete pPoEntry;
break; break;
} }
if( !pPoEntry->isFuzzy() && pPoEntry->getGroupId() == "RID_PRICING_FUNCTION_NAMES" ) if( !aPoEntry.isFuzzy() && aPoEntry.getGroupId() == "RID_PRICING_FUNCTION_NAMES" )
{ {
OString aMsgStr = pPoEntry->getMsgStr(); OString aMsgStr = aPoEntry.getMsgStr();
if( aMsgStr.isEmpty() ) if( aMsgStr.isEmpty() )
continue; continue;
if( aLocalizedCoreFunctionNames.find(aMsgStr) != aLocalizedCoreFunctionNames.end() ) if( aLocalizedCoreFunctionNames.find(aMsgStr) != aLocalizedCoreFunctionNames.end() )
aMsgStr += "_ADD"; aMsgStr += "_ADD";
if( aLocalizedFunctionNames.find(aMsgStr) == aLocalizedFunctionNames.end() ) { if( aLocalizedFunctionNames.find(aMsgStr) == aLocalizedFunctionNames.end() ) {
aLocalizedFunctionNames[aMsgStr] = 1; aLocalizedFunctionNames[aMsgStr] = 1;
delete pPoEntry;
} else { } else {
aLocalizedFunctionNames[aMsgStr]++; aLocalizedFunctionNames[aMsgStr]++;
repeatedEntries.push_back(pPoEntry); repeatedEntries.push_back(aPoEntry);
} }
} }
} }
...@@ -331,9 +322,9 @@ static void checkFunctionNames(OString aLanguage) ...@@ -331,9 +322,9 @@ static void checkFunctionNames(OString aLanguage)
aPoInput.readEntry(aPoEntry); aPoInput.readEntry(aPoEntry);
if( aPoInput.eof() ) if( aPoInput.eof() )
break; break;
for ( std::list<PoEntry*>::iterator it=repeatedEntries.begin(); it!=repeatedEntries.end(); ++it) for ( std::list<PoEntry>::iterator it=repeatedEntries.begin(); it!=repeatedEntries.end(); ++it)
{ {
if ((*it)->getMsgId() == aPoEntry.getMsgId() && (*it)->getGroupId() == aPoEntry.getGroupId()) if (it->getMsgId() == aPoEntry.getMsgId() && it->getGroupId() == aPoEntry.getGroupId())
{ {
bError = true; bError = true;
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment