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
+8 -6
View File
@@ -7,10 +7,12 @@
const int MAX_THREADS=128;
MutexImpl_Win32 & GetThreadMutex()
static MutexImpl_Win32 *g_pThreadIdMutex = NULL;
static void InitThreadIdMutex()
{
static MutexImpl_Win32 mutex(NULL);
return mutex;
if( g_pThreadIdMutex != NULL )
return;
g_pThreadIdMutex = new MutexImpl_Win32(NULL);
}
static uint64_t g_ThreadIds[MAX_THREADS];
@@ -106,9 +108,9 @@ static DWORD WINAPI StartThread( LPVOID pData )
static int GetOpenSlot( uint64_t iID )
{
MutexImpl_Win32 & mutex = GetThreadMutex();
InitThreadIdMutex();
mutex.Lock();
g_pThreadIdMutex->Lock();
// Find an open slot in g_ThreadIds.
int slot = 0;
@@ -118,7 +120,7 @@ static int GetOpenSlot( uint64_t iID )
g_ThreadIds[slot] = iID;
mutex.Unlock();
g_pThreadIdMutex->Unlock();
return slot;
}