fixed memory leak

This commit is contained in:
Ken Martin 2002-09-24 13:24:10 -04:00
parent 72054b95fd
commit 9878f49dfc
1 changed files with 7 additions and 0 deletions

View File

@ -78,6 +78,13 @@ cmCommand *cmake::GetCommand(const char *name)
void cmake::AddCommand(cmCommand* wg)
{
std::string name = wg->GetName();
// if the command already exists, free the old one
RegisteredCommandsMap::iterator pos = m_Commands.find(name);
if (pos != m_Commands.end())
{
delete pos->second;
m_Commands.erase(pos);
}
m_Commands.insert( RegisteredCommandsMap::value_type(name, wg));
}