BUG: clean up memory leaks.

This commit is contained in:
Bill Hoffman 2001-06-04 10:18:03 -04:00
parent abab6bc000
commit a3cfcd9894
8 changed files with 74 additions and 8 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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();

View File

@ -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();

View File

@ -72,6 +72,8 @@ public:
* regular CMakeList file
*/
virtual void ScopeEnded(const cmMakefile &mf) const {}
virtual ~cmFunctionBlocker() {}
};
#endif

View File

@ -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();
}

View File

@ -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;
}
}

View File

@ -82,6 +82,7 @@ public:
*/
virtual void ComputeSystemInfo() = 0;
virtual ~cmMakefileGenerator(){};
protected:
cmMakefile* m_Makefile;
};