[Cmake-commits] CMake branch, next, updated. v3.1.0-1489-gdc834a6

Stephen Kelly steveire at gmail.com
Sun Jan 4 10:55:33 EST 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  dc834a64ff36cf9f7d8863bcb26862ca00c602e0 (commit)
       via  2b14fd9b2f2d19fd5f44ce8c3047125233c01943 (commit)
       via  65a39f05ac1913daa08173429f76f6df60e07502 (commit)
       via  eb754045d93a75e290905409071da88c8cdd49b4 (commit)
       via  727980e93918d8df3847a17c608abe49432254c7 (commit)
       via  5216c48224a24c1c3d59b3535ee9c851c6c19636 (commit)
       via  3fba119f099cc7d6a1597d5bdc112c8f79ee0bcd (commit)
      from  c0dec596d1fadce47a9188a2a7f1b53c62852b72 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dc834a64ff36cf9f7d8863bcb26862ca00c602e0
commit dc834a64ff36cf9f7d8863bcb26862ca00c602e0
Merge: c0dec59 2b14fd9
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jan 4 10:55:30 2015 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sun Jan 4 10:55:30 2015 -0500

    Merge topic 'delete-algorithm' into next
    
    2b14fd9b Use the cmDeleteAll algorithm for types derived from std::map.
    65a39f05 cmDeleteAll: Generalize deletion specialization for map types.
    eb754045 cmVariableWatch: Use the cmDeleteAll algorithm with for_each.
    727980e9 cmGeneratorExpressionEvaluator: Replace own algorithm with cmDeleteAll.
    5216c482 Use the cmDeleteAll algorithm instead of trivial raw loops.
    3fba119f Add a generic algorithm for deleting items in a container.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2b14fd9b2f2d19fd5f44ce8c3047125233c01943
commit 2b14fd9b2f2d19fd5f44ce8c3047125233c01943
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jan 4 15:06:37 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Jan 4 16:36:48 2015 +0100

    Use the cmDeleteAll algorithm for types derived from std::map.

diff --git a/Source/cmExportSetMap.cxx b/Source/cmExportSetMap.cxx
index 5174118..14c4458 100644
--- a/Source/cmExportSetMap.cxx
+++ b/Source/cmExportSetMap.cxx
@@ -25,12 +25,7 @@ cmExportSet* cmExportSetMap::operator[](const std::string &name)
 
 void cmExportSetMap::clear()
 {
-  for(std::map<std::string, cmExportSet*>::iterator it = this->begin();
-      it != this->end();
-      ++ it)
-    {
-    delete it->second;
-    }
+  cmDeleteAll(*this);
   this->derived::clear();
 }
 
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 721c2ab..1549322 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1510,11 +1510,7 @@ void cmGlobalGenerator::CreateGeneratorTargets()
 //----------------------------------------------------------------------------
 void cmGlobalGenerator::ClearGeneratorMembers()
 {
-  for(cmGeneratorTargetsType::iterator i = this->GeneratorTargets.begin();
-      i != this->GeneratorTargets.end(); ++i)
-    {
-    delete i->second;
-    }
+  cmDeleteAll(this->GeneratorTargets);
   this->GeneratorTargets.clear();
 
   cmDeleteAll(this->EvaluationFiles);
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 3f09b9e..0eb47a9 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -542,12 +542,7 @@ void cmTarget::ClearLinkMaps()
   this->Internal->LinkInterfaceMap.clear();
   this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear();
   this->Internal->LinkClosureMap.clear();
-  for (cmTargetLinkInformationMap::const_iterator it
-      = this->LinkInformation.begin();
-      it != this->LinkInformation.end(); ++it)
-    {
-    delete it->second;
-    }
+  cmDeleteAll(this->LinkInformation);
   this->LinkInformation.clear();
 }
 
@@ -6913,10 +6908,7 @@ cmTargetLinkInformationMap
 //----------------------------------------------------------------------------
 cmTargetLinkInformationMap::~cmTargetLinkInformationMap()
 {
-  for(derived::iterator i = this->begin(); i != this->end(); ++i)
-    {
-    delete i->second;
-    }
+  cmDeleteAll(*this);
 }
 
 //----------------------------------------------------------------------------

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=65a39f05ac1913daa08173429f76f6df60e07502
commit 65a39f05ac1913daa08173429f76f6df60e07502
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jan 4 15:16:56 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Jan 4 16:36:48 2015 +0100

    cmDeleteAll: Generalize deletion specialization for map types.
    
    Assume that a container whose const_iterator to a container which
    has a value_type which in turn has a second_type should have the
    second member deleted.
    
    Use a C++17-style voider to implement the type introspection.

diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h
index 853413d..af060a3 100644
--- a/Source/cmStandardIncludes.h
+++ b/Source/cmStandardIncludes.h
@@ -448,7 +448,26 @@ private:
 
 namespace ContainerAlgorithms {
 
-template<typename Container>
+template<typename> struct voider { typedef void type; };
+
+template<typename T, typename = void>
+struct HasSecondType
+{
+  enum { value = false };
+};
+
+template<typename T>
+struct HasSecondType<T, typename voider<typename T::second_type>::type>
+{
+  enum { value = true };
+};
+
+template<typename Container,
+    bool hasSecondType = HasSecondType<
+        typename std::iterator_traits<
+            typename Container::const_iterator
+            >::value_type
+        >::value>
 struct DefaultDeleter
 {
   void operator()(typename Container::value_type value) {
@@ -456,10 +475,10 @@ struct DefaultDeleter
   }
 };
 
-template<typename K, typename V>
-struct DefaultDeleter<std::map<K, V> >
+template<typename Container>
+struct DefaultDeleter<Container, /* hasSecondType = */ true>
 {
-  void operator()(typename std::map<K, V>::value_type value) {
+  void operator()(typename Container::value_type value) {
     delete value.second;
   }
 };

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=eb754045d93a75e290905409071da88c8cdd49b4
commit eb754045d93a75e290905409071da88c8cdd49b4
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jan 4 16:33:15 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Jan 4 16:36:48 2015 +0100

    cmVariableWatch: Use the cmDeleteAll algorithm with for_each.

diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx
index cb6cb12..b8a6df2 100644
--- a/Source/cmVariableWatch.cxx
+++ b/Source/cmVariableWatch.cxx
@@ -34,21 +34,16 @@ cmVariableWatch::cmVariableWatch()
 {
 }
 
-cmVariableWatch::~cmVariableWatch()
+template<typename C>
+void deleteAllSecond(typename C::value_type it)
 {
-  cmVariableWatch::StringToVectorOfPairs::iterator svp_it;
-
-  for ( svp_it = this->WatchMap.begin();
-        svp_it != this->WatchMap.end(); ++svp_it )
-    {
-    cmVariableWatch::VectorOfPairs::iterator p_it;
+  cmDeleteAll(it.second);
+}
 
-    for ( p_it = svp_it->second.begin();
-          p_it != svp_it->second.end(); ++p_it )
-      {
-      delete *p_it;
-      }
-    }
+cmVariableWatch::~cmVariableWatch()
+{
+  std::for_each(this->WatchMap.begin(), this->WatchMap.end(),
+                deleteAllSecond<cmVariableWatch::StringToVectorOfPairs>);
 }
 
 bool cmVariableWatch::AddWatch(const std::string& variable,

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=727980e93918d8df3847a17c608abe49432254c7
commit 727980e93918d8df3847a17c608abe49432254c7
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jan 4 16:35:26 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Jan 4 16:36:48 2015 +0100

    cmGeneratorExpressionEvaluator: Replace own algorithm with cmDeleteAll.

diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 7ddf4d0..8d4c0c5 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -2054,30 +2054,9 @@ std::string GeneratorExpressionContent::EvaluateParameters(
 }
 
 //----------------------------------------------------------------------------
-static void deleteAll(const std::vector<cmGeneratorExpressionEvaluator*> &c)
-{
-  std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it
-                                                  = c.begin();
-  const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
-                                                  = c.end();
-  for ( ; it != end; ++it)
-    {
-    delete *it;
-    }
-}
-
-//----------------------------------------------------------------------------
 GeneratorExpressionContent::~GeneratorExpressionContent()
 {
-  deleteAll(this->IdentifierChildren);
-
-  typedef std::vector<cmGeneratorExpressionEvaluator*> EvaluatorVector;
-  std::vector<EvaluatorVector>::const_iterator pit =
-                                                  this->ParamChildren.begin();
-  const std::vector<EvaluatorVector>::const_iterator pend =
-                                                  this->ParamChildren.end();
-  for ( ; pit != pend; ++pit)
-    {
-    deleteAll(*pit);
-    }
+  cmDeleteAll(this->IdentifierChildren);
+  std::for_each(this->ParamChildren.begin(), this->ParamChildren.end(),
+                cmDeleteAll<std::vector<cmGeneratorExpressionEvaluator*> >);
 }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5216c48224a24c1c3d59b3535ee9c851c6c19636
commit 5216c48224a24c1c3d59b3535ee9c851c6c19636
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jan 4 13:33:16 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Jan 4 16:36:40 2015 +0100

    Use the cmDeleteAll algorithm instead of trivial raw loops.

diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx
index 94ca536..a07c29a 100644
--- a/Source/CPack/cmCPackGeneratorFactory.cxx
+++ b/Source/CPack/cmCPackGeneratorFactory.cxx
@@ -158,11 +158,7 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory()
 //----------------------------------------------------------------------
 cmCPackGeneratorFactory::~cmCPackGeneratorFactory()
 {
-  std::vector<cmCPackGenerator*>::iterator it;
-  for ( it = this->Generators.begin(); it != this->Generators.end(); ++ it )
-    {
-    delete *it;
-    }
+  cmDeleteAll(this->Generators);
 }
 
 //----------------------------------------------------------------------
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index 4200e9e..248efaf 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -69,11 +69,7 @@ cmCursesMainForm::~cmCursesMainForm()
   // Clean-up composites
   if (this->Entries)
     {
-    std::vector<cmCursesCacheEntryComposite*>::iterator it;
-    for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
-      {
-      delete *it;
-      }
+    cmDeleteAll(*this->Entries);
     }
   delete this->Entries;
   if (this->CMakeInstance)
@@ -188,12 +184,7 @@ void cmCursesMainForm::InitializeUI()
   // Clean old entries
   if (this->Entries)
     {
-    // Have to call delete on each pointer
-    std::vector<cmCursesCacheEntryComposite*>::iterator it;
-    for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
-      {
-      delete *it;
-      }
+    cmDeleteAll(*this->Entries);
     }
   delete this->Entries;
   this->Entries = newEntries;
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 80dbaf3..1879bf7 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -378,13 +378,7 @@ cmCTest::cmCTest()
 //----------------------------------------------------------------------
 cmCTest::~cmCTest()
 {
-  cmCTest::t_TestingHandlers::iterator it;
-  for ( it = this->TestingHandlers.begin();
-    it != this->TestingHandlers.end(); ++ it )
-    {
-    delete it->second;
-    it->second = 0;
-    }
+  cmDeleteAll(this->TestingHandlers);
   this->SetOutputLogFileName(0);
 }
 
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index a636d23..ed2026c 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -200,12 +200,7 @@ cmComputeLinkDepends
 //----------------------------------------------------------------------------
 cmComputeLinkDepends::~cmComputeLinkDepends()
 {
-  for(std::vector<DependSetList*>::iterator
-        i = this->InferredDependSets.begin();
-      i != this->InferredDependSets.end(); ++i)
-    {
-    delete *i;
-    }
+  cmDeleteAll(this->InferredDependSets);
   delete this->CCG;
 }
 
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index a1fc268..bedd0aa 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -90,12 +90,7 @@ cmDependsC::cmDependsC(cmLocalGenerator* lg,
 cmDependsC::~cmDependsC()
 {
   this->WriteCacheFile();
-
-  for (std::map<std::string, cmIncludeLines*>::iterator it=
-         this->FileCache.begin(); it!=this->FileCache.end(); ++it)
-    {
-    delete it->second;
-    }
+  cmDeleteAll(this->FileCache);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx
index 3ff1017..a268d12 100644
--- a/Source/cmDocumentation.cxx
+++ b/Source/cmDocumentation.cxx
@@ -87,12 +87,7 @@ cmDocumentation::cmDocumentation()
 //----------------------------------------------------------------------------
 cmDocumentation::~cmDocumentation()
 {
-  for(std::map<std::string,cmDocumentationSection *>::iterator i =
-        this->AllSections.begin();
-      i != this->AllSections.end(); ++i)
-    {
-    delete i->second;
-    }
+  cmDeleteAll(this->AllSections);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmExportSet.cxx b/Source/cmExportSet.cxx
index 33b0630..14812e4 100644
--- a/Source/cmExportSet.cxx
+++ b/Source/cmExportSet.cxx
@@ -15,10 +15,7 @@
 
 cmExportSet::~cmExportSet()
 {
-  for(unsigned int i = 0; i < this->TargetExports.size(); ++ i)
-    {
-    delete this->TargetExports[i];
-    }
+  cmDeleteAll(this->TargetExports);
 }
 
 void cmExportSet::AddTargetExport(cmTargetExport* te)
diff --git a/Source/cmFileLockPool.cxx b/Source/cmFileLockPool.cxx
index 551a75a..cf8e9a9 100644
--- a/Source/cmFileLockPool.cxx
+++ b/Source/cmFileLockPool.cxx
@@ -23,16 +23,8 @@ cmFileLockPool::cmFileLockPool()
 
 cmFileLockPool::~cmFileLockPool()
 {
-  for (It i = this->FunctionScopes.begin();
-      i != this->FunctionScopes.end(); ++i)
-    {
-    delete *i;
-    }
-
-  for (It i = this->FileScopes.begin(); i != this->FileScopes.end(); ++i)
-    {
-    delete *i;
-    }
+  cmDeleteAll(this->FunctionScopes);
+  cmDeleteAll(this->FileScopes);
 }
 
 void cmFileLockPool::PushFunctionScope()
@@ -148,10 +140,7 @@ cmFileLockPool::ScopePool::ScopePool()
 
 cmFileLockPool::ScopePool::~ScopePool()
 {
-  for (It i = this->Locks.begin(); i != this->Locks.end(); ++i)
-    {
-    delete *i;
-    }
+  cmDeleteAll(this->Locks);
 }
 
 cmFileLockResult cmFileLockPool::ScopePool::Lock(
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index 861122c..b2a2386 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -150,15 +150,7 @@ cmCompiledGeneratorExpression::cmCompiledGeneratorExpression(
 //----------------------------------------------------------------------------
 cmCompiledGeneratorExpression::~cmCompiledGeneratorExpression()
 {
-  std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it
-                                                  = this->Evaluators.begin();
-  const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
-                                                  = this->Evaluators.end();
-
-  for ( ; it != end; ++it)
-    {
-    delete *it;
-    }
+  cmDeleteAll(this->Evaluators);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index dd7fbc8..721c2ab 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1517,27 +1517,13 @@ void cmGlobalGenerator::ClearGeneratorMembers()
     }
   this->GeneratorTargets.clear();
 
-  for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator
-      li = this->EvaluationFiles.begin();
-      li != this->EvaluationFiles.end();
-      ++li)
-    {
-    delete *li;
-    }
+  cmDeleteAll(this->EvaluationFiles);
   this->EvaluationFiles.clear();
 
-  for(std::map<std::string, cmExportBuildFileGenerator*>::iterator
-        i = this->BuildExportSets.begin();
-      i != this->BuildExportSets.end(); ++i)
-    {
-    delete i->second;
-    }
+  cmDeleteAll(this->BuildExportSets);
   this->BuildExportSets.clear();
 
-  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
-    {
-    delete this->LocalGenerators[i];
-    }
+  cmDeleteAll(this->LocalGenerators);
   this->LocalGenerators.clear();
 
   this->ExportSets.clear();
diff --git a/Source/cmInstalledFile.h b/Source/cmInstalledFile.h
index 7134a4e..503f92c 100644
--- a/Source/cmInstalledFile.h
+++ b/Source/cmInstalledFile.h
@@ -38,11 +38,7 @@ public:
 
     ~Property()
     {
-      for(ExpressionVectorType::iterator i = ValueExpressions.begin();
-        i != ValueExpressions.end(); ++i)
-        {
-        delete *i;
-        }
+      cmDeleteAll(this->ValueExpressions);
     }
 
     ExpressionVectorType ValueExpressions;
diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx
index 1499e57..54b8535 100644
--- a/Source/cmMakeDepend.cxx
+++ b/Source/cmMakeDepend.cxx
@@ -34,12 +34,7 @@ cmMakeDepend::cmMakeDepend()
 
 cmMakeDepend::~cmMakeDepend()
 {
-  for(DependInformationMapType::iterator i =
-        this->DependInformationMap.begin();
-      i != this->DependInformationMap.end(); ++i)
-    {
-    delete i->second;
-    }
+  cmDeleteAll(this->DependInformationMap);
 }
 
 
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 20dae5a..d93a46f 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -194,45 +194,13 @@ bool cmMakefile::NeedCacheCompatibility(int major, int minor) const
 
 cmMakefile::~cmMakefile()
 {
-  for(std::vector<cmInstallGenerator*>::iterator
-        i = this->InstallGenerators.begin();
-      i != this->InstallGenerators.end(); ++i)
-    {
-    delete *i;
-    }
-  for(std::vector<cmTestGenerator*>::iterator
-        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;
-    }
+  cmDeleteAll(this->InstallGenerators);
+  cmDeleteAll(this->TestGenerators);
+  cmDeleteAll(this->SourceFiles);
+  cmDeleteAll(this->Tests);
+  cmDeleteAll(this->ImportedTargetsOwned);
+  cmDeleteAll(this->FinalPassCommands);
+  cmDeleteAll(this->FunctionBlockers);
   this->FunctionBlockers.clear();
   if (this->PolicyStack.size() != 1)
   {
diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx
index 3cdd2f6..6c4609a 100644
--- a/Source/cmOrderDirectories.cxx
+++ b/Source/cmOrderDirectories.cxx
@@ -291,18 +291,8 @@ cmOrderDirectories::cmOrderDirectories(cmGlobalGenerator* gg,
 //----------------------------------------------------------------------------
 cmOrderDirectories::~cmOrderDirectories()
 {
-  for(std::vector<cmOrderDirectoriesConstraint*>::iterator
-        i = this->ConstraintEntries.begin();
-      i != this->ConstraintEntries.end(); ++i)
-    {
-    delete *i;
-    }
-  for(std::vector<cmOrderDirectoriesConstraint*>::iterator
-        i = this->ImplicitDirEntries.begin();
-      i != this->ImplicitDirEntries.end(); ++i)
-    {
-    delete *i;
-    }
+  cmDeleteAll(this->ConstraintEntries);
+  cmDeleteAll(this->ImplicitDirEntries);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 1a27a25..ad40565 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -378,13 +378,7 @@ cmPolicies::cmPolicies()
 
 cmPolicies::~cmPolicies()
 {
-  // free the policies
-  std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i
-    = this->Policies.begin();
-  for (;i != this->Policies.end(); ++i)
-    {
-    delete i->second;
-    }
+  cmDeleteAll(this->Policies);
 }
 
 void cmPolicies::DefinePolicy(cmPolicies::PolicyID iD,
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 94a6de3..3f09b9e 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -226,13 +226,7 @@ cmLinkImplItem cmTargetInternals::TargetPropertyEntry::NoLinkImplItem;
 static void deleteAndClear(
       std::vector<cmTargetInternals::TargetPropertyEntry*> &entries)
 {
-  for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator
-      it = entries.begin(),
-      end = entries.end();
-      it != end; ++it)
-    {
-      delete *it;
-    }
+  cmDeleteAll(entries);
   entries.clear();
 }
 
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index bbd3fe4..da265e3 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -171,16 +171,8 @@ cmake::~cmake()
     delete this->GlobalGenerator;
     this->GlobalGenerator = 0;
     }
-  for(RegisteredCommandsMap::iterator j = this->Commands.begin();
-      j != this->Commands.end(); ++j)
-    {
-    delete (*j).second;
-    }
-  for(RegisteredGeneratorsVector::iterator j = this->Generators.begin();
-      j != this->Generators.end(); ++j)
-    {
-    delete *j;
-    }
+  cmDeleteAll(this->Commands);
+  cmDeleteAll(this->Generators);
 #ifdef CMAKE_BUILD_WITH_CMAKE
   delete this->VariableWatch;
 #endif

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3fba119f099cc7d6a1597d5bdc112c8f79ee0bcd
commit 3fba119f099cc7d6a1597d5bdc112c8f79ee0bcd
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jan 4 14:53:24 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Jan 4 15:57:10 2015 +0100

    Add a generic algorithm for deleting items in a container.
    
    Specialize for std::map types to delete the second element from
    the iterator.  This is not quite general enough that it can
    be used everywhere, because CMake inherits from std::map and
    creates typedefs with custom comparison functors etc, which
    can not use this algorithm.

diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h
index 6b85634..853413d 100644
--- a/Source/cmStandardIncludes.h
+++ b/Source/cmStandardIncludes.h
@@ -446,4 +446,31 @@ private:
   const std::string m_test;
 };
 
+namespace ContainerAlgorithms {
+
+template<typename Container>
+struct DefaultDeleter
+{
+  void operator()(typename Container::value_type value) {
+    delete value;
+  }
+};
+
+template<typename K, typename V>
+struct DefaultDeleter<std::map<K, V> >
+{
+  void operator()(typename std::map<K, V>::value_type value) {
+    delete value.second;
+  }
+};
+
+}
+
+template<typename Container>
+void cmDeleteAll(Container const& c)
+{
+  std::for_each(c.begin(), c.end(),
+                ContainerAlgorithms::DefaultDeleter<Container>());
+}
+
 #endif

-----------------------------------------------------------------------

Summary of changes:
 Source/CPack/cmCPackGeneratorFactory.cxx  |    6 +---
 Source/CursesDialog/cmCursesMainForm.cxx  |   13 ++------
 Source/cmCTest.cxx                        |    8 +----
 Source/cmComputeLinkDepends.cxx           |    7 +----
 Source/cmDependsC.cxx                     |    7 +----
 Source/cmDocumentation.cxx                |    7 +----
 Source/cmExportSet.cxx                    |    5 +---
 Source/cmExportSetMap.cxx                 |    7 +----
 Source/cmFileLockPool.cxx                 |   17 ++---------
 Source/cmGeneratorExpression.cxx          |   10 +------
 Source/cmGeneratorExpressionEvaluator.cxx |   27 ++---------------
 Source/cmGlobalGenerator.cxx              |   26 +++-------------
 Source/cmInstalledFile.h                  |    6 +---
 Source/cmMakeDepend.cxx                   |    7 +----
 Source/cmMakefile.cxx                     |   46 +++++------------------------
 Source/cmOrderDirectories.cxx             |   14 ++-------
 Source/cmPolicies.cxx                     |    8 +----
 Source/cmStandardIncludes.h               |   46 +++++++++++++++++++++++++++++
 Source/cmTarget.cxx                       |   20 ++-----------
 Source/cmVariableWatch.cxx                |   21 +++++--------
 Source/cmake.cxx                          |   12 ++------
 21 files changed, 91 insertions(+), 229 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list