summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2001-06-04 14:18:03 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2001-06-04 14:18:03 (GMT)
commita3cfcd9894a5d626b8beba80fc8b5934ea3f46cf (patch)
tree73155ed903d3138946d64f4da4631954c8601b4e /Source
parentabab6bc00069df6ff1988abced39b98ea199febc (diff)
downloadCMake-a3cfcd9894a5d626b8beba80fc8b5934ea3f46cf.zip
CMake-a3cfcd9894a5d626b8beba80fc8b5934ea3f46cf.tar.gz
CMake-a3cfcd9894a5d626b8beba80fc8b5934ea3f46cf.tar.bz2
BUG: clean up memory leaks.
Diffstat (limited to 'Source')
-rw-r--r--Source/MFCDialog/CMakeSetupDialog.cpp12
-rw-r--r--Source/cmCacheManager.cxx12
-rw-r--r--Source/cmDSWMakefile.cxx15
-rw-r--r--Source/cmDSWWriter.cxx15
-rw-r--r--Source/cmFunctionBlocker.h2
-rw-r--r--Source/cmMSProjectGenerator.cxx4
-rw-r--r--Source/cmMakefile.cxx21
-rw-r--r--Source/cmMakefileGenerator.h1
8 files changed, 74 insertions, 8 deletions
diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp
index 0505e50..d6819eb 100644
--- a/Source/MFCDialog/CMakeSetupDialog.cpp
+++ b/Source/MFCDialog/CMakeSetupDialog.cpp
@@ -219,6 +219,17 @@ int CALLBACK CMakeSetupDialog_SetSelProc( HWND hWnd, UINT uMsg,
return 0;
}
+inline void ILFree(LPITEMIDLIST pidl)
+{
+ LPMALLOC pMalloc;
+ if (pidl)
+ {
+ SHGetMalloc(&pMalloc);
+ pMalloc->Free( pidl);
+ pMalloc->Release();
+ }
+}
+
// Browse button
bool CMakeSetupDialog::Browse(CString &result, const char *title)
@@ -243,6 +254,7 @@ bool CMakeSetupDialog::Browse(CString &result, const char *title)
{
result = szPathName;
}
+ ILFree(pidl);
return bSuccess;
}
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index d183e23..b28ec3e 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -70,12 +70,24 @@ cmCacheManager::CacheEntryType cmCacheManager::StringToType(const char* s)
}
+struct CleanUpCacheManager
+{
+ ~CleanUpCacheManager()
+ {
+ delete cmCacheManager::GetInstance();
+ }
+ void Use() {}
+};
+
+CleanUpCacheManager cleanup;
+
cmCacheManager* cmCacheManager::s_Instance = 0;
cmCacheManager* cmCacheManager::GetInstance()
{
if(!cmCacheManager::s_Instance)
{
+ cleanup.Use();
cmCacheManager::s_Instance = new cmCacheManager;
}
return cmCacheManager::s_Instance;
diff --git a/Source/cmDSWMakefile.cxx b/Source/cmDSWMakefile.cxx
index cd3feb7..0823869 100644
--- a/Source/cmDSWMakefile.cxx
+++ b/Source/cmDSWMakefile.cxx
@@ -96,7 +96,6 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
// add a special target that depends on ALL projects for easy build
// of Debug only
m_Makefile->AddUtilityCommand("ALL_BUILD", "echo \"Build all projects\"", false);
-
m_Makefile->FindSubDirectoryCMakeListsFiles(allListFiles);
// For each cmMakefile, create a DSP for it, and
// add it to this DSW file
@@ -104,8 +103,18 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
k != allListFiles.end(); ++k)
{
cmMakefile* mf = *k;
- // Create an MS generator with DSW off, so it only creates dsp files
- cmMSProjectGenerator* pg = new cmMSProjectGenerator;
+ cmMSProjectGenerator* pg = 0;
+ // if not this makefile, then create a new generator
+ if(m_Makefile != mf)
+ {
+ // Create an MS generator with DSW off, so it only creates dsp files
+ pg = new cmMSProjectGenerator;
+ }
+ else
+ {
+ pg = (cmMSProjectGenerator*)m_Makefile->GetMakefileGenerator();
+ }
+ // make sure the generator is building dsp files
pg->BuildDSWOff();
mf->SetMakefileGenerator(pg);
mf->GenerateMakefile();
diff --git a/Source/cmDSWWriter.cxx b/Source/cmDSWWriter.cxx
index cd3feb7..0823869 100644
--- a/Source/cmDSWWriter.cxx
+++ b/Source/cmDSWWriter.cxx
@@ -96,7 +96,6 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
// add a special target that depends on ALL projects for easy build
// of Debug only
m_Makefile->AddUtilityCommand("ALL_BUILD", "echo \"Build all projects\"", false);
-
m_Makefile->FindSubDirectoryCMakeListsFiles(allListFiles);
// For each cmMakefile, create a DSP for it, and
// add it to this DSW file
@@ -104,8 +103,18 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
k != allListFiles.end(); ++k)
{
cmMakefile* mf = *k;
- // Create an MS generator with DSW off, so it only creates dsp files
- cmMSProjectGenerator* pg = new cmMSProjectGenerator;
+ cmMSProjectGenerator* pg = 0;
+ // if not this makefile, then create a new generator
+ if(m_Makefile != mf)
+ {
+ // Create an MS generator with DSW off, so it only creates dsp files
+ pg = new cmMSProjectGenerator;
+ }
+ else
+ {
+ pg = (cmMSProjectGenerator*)m_Makefile->GetMakefileGenerator();
+ }
+ // make sure the generator is building dsp files
pg->BuildDSWOff();
mf->SetMakefileGenerator(pg);
mf->GenerateMakefile();
diff --git a/Source/cmFunctionBlocker.h b/Source/cmFunctionBlocker.h
index 5c8c70d..3891ff1 100644
--- a/Source/cmFunctionBlocker.h
+++ b/Source/cmFunctionBlocker.h
@@ -72,6 +72,8 @@ public:
* regular CMakeList file
*/
virtual void ScopeEnded(const cmMakefile &mf) const {}
+
+ virtual ~cmFunctionBlocker() {}
};
#endif
diff --git a/Source/cmMSProjectGenerator.cxx b/Source/cmMSProjectGenerator.cxx
index 12e2733..7ac4106 100644
--- a/Source/cmMSProjectGenerator.cxx
+++ b/Source/cmMSProjectGenerator.cxx
@@ -54,11 +54,15 @@ void cmMSProjectGenerator::GenerateMakefile()
{
if(m_BuildDSW)
{
+ delete m_DSWMakefile;
+ m_DSWMakefile = 0;
m_DSWMakefile = new cmDSWMakefile(m_Makefile);
m_DSWMakefile->OutputDSWFile();
}
else
{
+ delete m_DSPMakefile;
+ m_DSPMakefile = 0;
m_DSPMakefile = new cmDSPMakefile(m_Makefile);
m_DSPMakefile->OutputDSPFile();
}
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 134fdf9..446729e 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -111,6 +111,14 @@ cmMakefile::~cmMakefile()
delete d->second;
}
}
+ std::set<cmFunctionBlocker *>::const_iterator pos;
+ for (pos = m_FunctionBlockers.begin();
+ pos != m_FunctionBlockers.end(); ++pos)
+ {
+ cmFunctionBlocker* b = *pos;
+ m_FunctionBlockers.erase(*pos);
+ delete b;
+ }
delete m_MakefileGenerator;
}
@@ -189,7 +197,10 @@ bool cmMakefile::ReadListFile(const char* filename, const char* external)
// keep track of the current file being read
if (filename)
{
- m_cmCurrentListFile= filename;
+ if(m_cmCurrentListFile != filename)
+ {
+ m_cmCurrentListFile = filename;
+ }
}
// if this is not a remote makefile
@@ -342,6 +353,10 @@ void cmMakefile::AddCommand(cmCommand* wg)
// Set the make file
void cmMakefile::SetMakefileGenerator(cmMakefileGenerator* mf)
{
+ if(mf == m_MakefileGenerator)
+ {
+ return;
+ }
delete m_MakefileGenerator;
m_MakefileGenerator = mf;
mf->SetMakefile(this);
@@ -836,7 +851,7 @@ bool cmMakefile::IsFunctionBlocked(const char *name,
}
void cmMakefile::RemoveFunctionBlocker(const char *name,
- const std::vector<std::string> &args)
+ const std::vector<std::string> &args)
{
// loop over all function blockers to see if any block this command
std::set<cmFunctionBlocker *>::const_iterator pos;
@@ -845,7 +860,9 @@ void cmMakefile::RemoveFunctionBlocker(const char *name,
{
if ((*pos)->ShouldRemove(name, args, *this))
{
+ cmFunctionBlocker* b = *pos;
m_FunctionBlockers.erase(*pos);
+ delete b;
return;
}
}
diff --git a/Source/cmMakefileGenerator.h b/Source/cmMakefileGenerator.h
index a44e62b..688d31f 100644
--- a/Source/cmMakefileGenerator.h
+++ b/Source/cmMakefileGenerator.h
@@ -82,6 +82,7 @@ public:
*/
virtual void ComputeSystemInfo() = 0;
+ virtual ~cmMakefileGenerator(){};
protected:
cmMakefile* m_Makefile;
};