Revert memory leak commits

5f7001e: "Added a new branch"
01456ed: "Fixed a lot of memory leaks"
dac4493: "Fixed all remaining memory leaks that I could figure out"
0792db7: "Removed the smnew macro and the call to _CrtSetDbgFlag()"

Some of these caused destructor-time problems due to static initialization
order fiasco and related issues.  Notably, the program would no longer exit on
OSX and had to be killed.

There were probably legitimate fixes in here, but since these are monolithic
commits it's too much work to extract them now.  Let's reapply them
individually and in the forward direction.
This commit is contained in:
Devin J. Pohly
2013-04-27 00:05:14 -04:00
parent ef9c5294a0
commit feb919f0bf
33 changed files with 182 additions and 266 deletions
+9 -15
View File
@@ -14,26 +14,22 @@
// Actor registration
map<RString,CreateActorFn> & GetActorUtilRegistrees()
{
static map<RString, CreateActorFn> registrees;
return registrees;
}
static map<RString,CreateActorFn> *g_pmapRegistrees = NULL;
static bool IsRegistered( const RString& sClassName )
{
map<RString, CreateActorFn> & registrees = GetActorUtilRegistrees();
return registrees.find( sClassName ) != registrees.end();
return g_pmapRegistrees->find( sClassName ) != g_pmapRegistrees->end();
}
void ActorUtil::Register( const RString& sClassName, CreateActorFn pfn )
{
map<RString, CreateActorFn> & registrees = GetActorUtilRegistrees();
if( g_pmapRegistrees == NULL )
g_pmapRegistrees = new map<RString,CreateActorFn>;
map<RString,CreateActorFn>::iterator iter = registrees.find( sClassName );
ASSERT_M( iter == registrees.end(), ssprintf("Actor class '%s' already registered.", sClassName.c_str()) );
map<RString,CreateActorFn>::iterator iter = g_pmapRegistrees->find( sClassName );
ASSERT_M( iter == g_pmapRegistrees->end(), ssprintf("Actor class '%s' already registered.", sClassName.c_str()) );
registrees[sClassName] = pfn;
(*g_pmapRegistrees)[sClassName] = pfn;
}
bool ActorUtil::ResolvePath( RString &sPath, const RString &sName )
@@ -123,10 +119,8 @@ Actor* ActorUtil::LoadFromNode( const XNode* pNode, Actor *pParentActor )
if( !bHasClass )
bHasClass = pNode->GetAttrValue( "Type", sClass );
map<RString, CreateActorFn> & registrees = GetActorUtilRegistrees();
map<RString,CreateActorFn>::iterator iter = registrees.find( sClass );
if( iter == registrees.end() )
map<RString,CreateActorFn>::iterator iter = g_pmapRegistrees->find( sClass );
if( iter == g_pmapRegistrees->end() )
{
// sClass is invalid
RString sError = ssprintf( "%s: invalid Class \"%s\"",