Skip to content

Commit a81dba0

Browse files
authored
[GEN][ZH] Fix Null Memory Manager issues introduced by #1275 (#1289)
1 parent 106f217 commit a81dba0

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

Generals/Code/GameEngine/Source/Common/System/GameMemoryNull.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,13 @@ void initMemoryManager()
111111
{
112112
TheMemoryPoolFactory = new (malloc(sizeof MemoryPoolFactory)) MemoryPoolFactory;
113113
TheDynamicMemoryAllocator = new (malloc(sizeof DynamicMemoryAllocator)) DynamicMemoryAllocator;
114+
115+
DEBUG_INIT(DEBUG_FLAGS_DEFAULT);
116+
DEBUG_LOG(("*** Initialized the Null Memory Manager"));
114117
}
115118
else
116119
{
117-
DEBUG_CRASH(("memory manager is already inited"));
120+
DEBUG_CRASH(("Null Memory Manager is already initialized"));
118121
}
119122

120123
theMainInitFlag = true;
@@ -148,6 +151,8 @@ void shutdownMemoryManager()
148151
}
149152

150153
theMainInitFlag = false;
154+
155+
DEBUG_SHUTDOWN();
151156
}
152157

153158

Generals/Code/Main/WinMain.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,9 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
753753
TheMemoryPoolCriticalSection = &critSec4;
754754
TheDebugLogCriticalSection = &critSec5;
755755

756+
// initialize the memory manager early
757+
initMemoryManager();
758+
756759
/// @todo remove this force set of working directory later
757760
Char buffer[ _MAX_PATH ];
758761
GetModuleFileName( NULL, buffer, sizeof( buffer ) );
@@ -787,9 +790,6 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
787790
// Force to be loaded from a file, not a resource so same exe can be used in germany and retail.
788791
gLoadScreenBitmap = (HBITMAP)LoadImage(hInstance, "Install_Final.bmp", IMAGE_BITMAP, 0, 0, LR_SHARED|LR_LOADFROMFILE);
789792

790-
// initialize the memory manager early
791-
initMemoryManager();
792-
793793
CommandLine::parseCommandLineForStartup();
794794

795795
// register windows class and create application window

GeneralsMD/Code/GameEngine/Source/Common/System/GameMemoryNull.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,13 @@ void initMemoryManager()
111111
{
112112
TheMemoryPoolFactory = new (malloc(sizeof MemoryPoolFactory)) MemoryPoolFactory;
113113
TheDynamicMemoryAllocator = new (malloc(sizeof DynamicMemoryAllocator)) DynamicMemoryAllocator;
114+
115+
DEBUG_INIT(DEBUG_FLAGS_DEFAULT);
116+
DEBUG_LOG(("*** Initialized the Null Memory Manager"));
114117
}
115118
else
116119
{
117-
DEBUG_CRASH(("memory manager is already inited"));
120+
DEBUG_CRASH(("Null Memory Manager is already initialized"));
118121
}
119122

120123
theMainInitFlag = true;
@@ -148,6 +151,8 @@ void shutdownMemoryManager()
148151
}
149152

150153
theMainInitFlag = false;
154+
155+
DEBUG_SHUTDOWN();
151156
}
152157

153158

GeneralsMD/Code/Main/WinMain.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,9 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
779779
TheMemoryPoolCriticalSection = &critSec4;
780780
TheDebugLogCriticalSection = &critSec5;
781781

782+
// initialize the memory manager early
783+
initMemoryManager();
784+
782785
/// @todo remove this force set of working directory later
783786
Char buffer[ _MAX_PATH ];
784787
GetModuleFileName( NULL, buffer, sizeof( buffer ) );
@@ -833,9 +836,6 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
833836
gLoadScreenBitmap = (HBITMAP)LoadImage(hInstance, "Install_Final.bmp", IMAGE_BITMAP, 0, 0, LR_SHARED|LR_LOADFROMFILE);
834837
#endif
835838

836-
// initialize the memory manager early
837-
initMemoryManager();
838-
839839
CommandLine::parseCommandLineForStartup();
840840

841841
// register windows class and create application window

0 commit comments

Comments
 (0)