Use the cmDeleteAll algorithm instead of trivial raw loops.

This commit is contained in:
Stephen Kelly 2015-01-04 13:33:16 +01:00
parent abb4a6781f
commit 4a6e795b0c
17 changed files with 30 additions and 171 deletions

View File

@ -158,11 +158,7 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
cmCPackGeneratorFactory::~cmCPackGeneratorFactory() cmCPackGeneratorFactory::~cmCPackGeneratorFactory()
{ {
std::vector<cmCPackGenerator*>::iterator it; cmDeleteAll(this->Generators);
for ( it = this->Generators.begin(); it != this->Generators.end(); ++ it )
{
delete *it;
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -69,11 +69,7 @@ cmCursesMainForm::~cmCursesMainForm()
// Clean-up composites // Clean-up composites
if (this->Entries) if (this->Entries)
{ {
std::vector<cmCursesCacheEntryComposite*>::iterator it; cmDeleteAll(*this->Entries);
for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
{
delete *it;
}
} }
delete this->Entries; delete this->Entries;
if (this->CMakeInstance) if (this->CMakeInstance)
@ -188,12 +184,7 @@ void cmCursesMainForm::InitializeUI()
// Clean old entries // Clean old entries
if (this->Entries) if (this->Entries)
{ {
// Have to call delete on each pointer cmDeleteAll(*this->Entries);
std::vector<cmCursesCacheEntryComposite*>::iterator it;
for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
{
delete *it;
}
} }
delete this->Entries; delete this->Entries;
this->Entries = newEntries; this->Entries = newEntries;

View File

@ -378,13 +378,7 @@ cmCTest::cmCTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
cmCTest::~cmCTest() cmCTest::~cmCTest()
{ {
cmCTest::t_TestingHandlers::iterator it; cmDeleteAll(this->TestingHandlers);
for ( it = this->TestingHandlers.begin();
it != this->TestingHandlers.end(); ++ it )
{
delete it->second;
it->second = 0;
}
this->SetOutputLogFileName(0); this->SetOutputLogFileName(0);
} }

View File

@ -200,12 +200,7 @@ cmComputeLinkDepends
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmComputeLinkDepends::~cmComputeLinkDepends() cmComputeLinkDepends::~cmComputeLinkDepends()
{ {
for(std::vector<DependSetList*>::iterator cmDeleteAll(this->InferredDependSets);
i = this->InferredDependSets.begin();
i != this->InferredDependSets.end(); ++i)
{
delete *i;
}
delete this->CCG; delete this->CCG;
} }

View File

@ -90,12 +90,7 @@ cmDependsC::cmDependsC(cmLocalGenerator* lg,
cmDependsC::~cmDependsC() cmDependsC::~cmDependsC()
{ {
this->WriteCacheFile(); this->WriteCacheFile();
cmDeleteAll(this->FileCache);
for (std::map<std::string, cmIncludeLines*>::iterator it=
this->FileCache.begin(); it!=this->FileCache.end(); ++it)
{
delete it->second;
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -87,12 +87,7 @@ cmDocumentation::cmDocumentation()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmDocumentation::~cmDocumentation() cmDocumentation::~cmDocumentation()
{ {
for(std::map<std::string,cmDocumentationSection *>::iterator i = cmDeleteAll(this->AllSections);
this->AllSections.begin();
i != this->AllSections.end(); ++i)
{
delete i->second;
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -15,10 +15,7 @@
cmExportSet::~cmExportSet() cmExportSet::~cmExportSet()
{ {
for(unsigned int i = 0; i < this->TargetExports.size(); ++ i) cmDeleteAll(this->TargetExports);
{
delete this->TargetExports[i];
}
} }
void cmExportSet::AddTargetExport(cmTargetExport* te) void cmExportSet::AddTargetExport(cmTargetExport* te)

View File

@ -23,16 +23,8 @@ cmFileLockPool::cmFileLockPool()
cmFileLockPool::~cmFileLockPool() cmFileLockPool::~cmFileLockPool()
{ {
for (It i = this->FunctionScopes.begin(); cmDeleteAll(this->FunctionScopes);
i != this->FunctionScopes.end(); ++i) cmDeleteAll(this->FileScopes);
{
delete *i;
}
for (It i = this->FileScopes.begin(); i != this->FileScopes.end(); ++i)
{
delete *i;
}
} }
void cmFileLockPool::PushFunctionScope() void cmFileLockPool::PushFunctionScope()
@ -148,10 +140,7 @@ cmFileLockPool::ScopePool::ScopePool()
cmFileLockPool::ScopePool::~ScopePool() cmFileLockPool::ScopePool::~ScopePool()
{ {
for (It i = this->Locks.begin(); i != this->Locks.end(); ++i) cmDeleteAll(this->Locks);
{
delete *i;
}
} }
cmFileLockResult cmFileLockPool::ScopePool::Lock( cmFileLockResult cmFileLockPool::ScopePool::Lock(

View File

@ -150,15 +150,7 @@ cmCompiledGeneratorExpression::cmCompiledGeneratorExpression(
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmCompiledGeneratorExpression::~cmCompiledGeneratorExpression() cmCompiledGeneratorExpression::~cmCompiledGeneratorExpression()
{ {
std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it cmDeleteAll(this->Evaluators);
= this->Evaluators.begin();
const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
= this->Evaluators.end();
for ( ; it != end; ++it)
{
delete *it;
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -1517,27 +1517,13 @@ void cmGlobalGenerator::ClearGeneratorMembers()
} }
this->GeneratorTargets.clear(); this->GeneratorTargets.clear();
for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator cmDeleteAll(this->EvaluationFiles);
li = this->EvaluationFiles.begin();
li != this->EvaluationFiles.end();
++li)
{
delete *li;
}
this->EvaluationFiles.clear(); this->EvaluationFiles.clear();
for(std::map<std::string, cmExportBuildFileGenerator*>::iterator cmDeleteAll(this->BuildExportSets);
i = this->BuildExportSets.begin();
i != this->BuildExportSets.end(); ++i)
{
delete i->second;
}
this->BuildExportSets.clear(); this->BuildExportSets.clear();
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) cmDeleteAll(this->LocalGenerators);
{
delete this->LocalGenerators[i];
}
this->LocalGenerators.clear(); this->LocalGenerators.clear();
this->ExportSets.clear(); this->ExportSets.clear();

View File

@ -38,11 +38,7 @@ public:
~Property() ~Property()
{ {
for(ExpressionVectorType::iterator i = ValueExpressions.begin(); cmDeleteAll(this->ValueExpressions);
i != ValueExpressions.end(); ++i)
{
delete *i;
}
} }
ExpressionVectorType ValueExpressions; ExpressionVectorType ValueExpressions;

View File

@ -34,12 +34,7 @@ cmMakeDepend::cmMakeDepend()
cmMakeDepend::~cmMakeDepend() cmMakeDepend::~cmMakeDepend()
{ {
for(DependInformationMapType::iterator i = cmDeleteAll(this->DependInformationMap);
this->DependInformationMap.begin();
i != this->DependInformationMap.end(); ++i)
{
delete i->second;
}
} }

View File

@ -194,45 +194,13 @@ bool cmMakefile::NeedCacheCompatibility(int major, int minor) const
cmMakefile::~cmMakefile() cmMakefile::~cmMakefile()
{ {
for(std::vector<cmInstallGenerator*>::iterator cmDeleteAll(this->InstallGenerators);
i = this->InstallGenerators.begin(); cmDeleteAll(this->TestGenerators);
i != this->InstallGenerators.end(); ++i) cmDeleteAll(this->SourceFiles);
{ cmDeleteAll(this->Tests);
delete *i; cmDeleteAll(this->ImportedTargetsOwned);
} cmDeleteAll(this->FinalPassCommands);
for(std::vector<cmTestGenerator*>::iterator cmDeleteAll(this->FunctionBlockers);
i = this->TestGenerators.begin();
i != this->TestGenerators.end(); ++i)
{
delete *i;
}
for(std::vector<cmSourceFile*>::iterator i = this->SourceFiles.begin();
i != this->SourceFiles.end(); ++i)
{
delete *i;
}
for(std::map<std::string, cmTest*>::iterator i = this->Tests.begin();
i != this->Tests.end(); ++i)
{
delete i->second;
}
for(std::vector<cmTarget*>::iterator
i = this->ImportedTargetsOwned.begin();
i != this->ImportedTargetsOwned.end(); ++i)
{
delete *i;
}
for(unsigned int i=0; i < this->FinalPassCommands.size(); i++)
{
delete this->FinalPassCommands[i];
}
std::vector<cmFunctionBlocker*>::iterator pos;
for (pos = this->FunctionBlockers.begin();
pos != this->FunctionBlockers.end(); ++pos)
{
cmFunctionBlocker* b = *pos;
delete b;
}
this->FunctionBlockers.clear(); this->FunctionBlockers.clear();
if (this->PolicyStack.size() != 1) if (this->PolicyStack.size() != 1)
{ {

View File

@ -291,18 +291,8 @@ cmOrderDirectories::cmOrderDirectories(cmGlobalGenerator* gg,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmOrderDirectories::~cmOrderDirectories() cmOrderDirectories::~cmOrderDirectories()
{ {
for(std::vector<cmOrderDirectoriesConstraint*>::iterator cmDeleteAll(this->ConstraintEntries);
i = this->ConstraintEntries.begin(); cmDeleteAll(this->ImplicitDirEntries);
i != this->ConstraintEntries.end(); ++i)
{
delete *i;
}
for(std::vector<cmOrderDirectoriesConstraint*>::iterator
i = this->ImplicitDirEntries.begin();
i != this->ImplicitDirEntries.end(); ++i)
{
delete *i;
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -378,13 +378,7 @@ cmPolicies::cmPolicies()
cmPolicies::~cmPolicies() cmPolicies::~cmPolicies()
{ {
// free the policies cmDeleteAll(this->Policies);
std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i
= this->Policies.begin();
for (;i != this->Policies.end(); ++i)
{
delete i->second;
}
} }
void cmPolicies::DefinePolicy(cmPolicies::PolicyID iD, void cmPolicies::DefinePolicy(cmPolicies::PolicyID iD,

View File

@ -226,13 +226,7 @@ cmLinkImplItem cmTargetInternals::TargetPropertyEntry::NoLinkImplItem;
static void deleteAndClear( static void deleteAndClear(
std::vector<cmTargetInternals::TargetPropertyEntry*> &entries) std::vector<cmTargetInternals::TargetPropertyEntry*> &entries)
{ {
for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator cmDeleteAll(entries);
it = entries.begin(),
end = entries.end();
it != end; ++it)
{
delete *it;
}
entries.clear(); entries.clear();
} }

View File

@ -171,16 +171,8 @@ cmake::~cmake()
delete this->GlobalGenerator; delete this->GlobalGenerator;
this->GlobalGenerator = 0; this->GlobalGenerator = 0;
} }
for(RegisteredCommandsMap::iterator j = this->Commands.begin(); cmDeleteAll(this->Commands);
j != this->Commands.end(); ++j) cmDeleteAll(this->Generators);
{
delete (*j).second;
}
for(RegisteredGeneratorsVector::iterator j = this->Generators.begin();
j != this->Generators.end(); ++j)
{
delete *j;
}
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
delete this->VariableWatch; delete this->VariableWatch;
#endif #endif