From 4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Mon, 13 Feb 2012 21:47:03 +0000 Subject: Rewritten most of the code for multithreading; still not 100%, but getting there. If this commit proves to be too problematic, we can always undo it. git-svn-id: http://mc-server.googlecode.com/svn/trunk@251 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/main.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 10 deletions(-) (limited to 'source/main.cpp') diff --git a/source/main.cpp b/source/main.cpp index 37b3be5ac..835d7ffc7 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -17,6 +17,22 @@ +/// If defined, a thorough leak finder will be used (debug MSVC only); leaks will be output to the Output window +#define ENABLE_LEAK_FINDER + + + + + +#if defined(_MSC_VER) && defined(_DEBUG) && defined(ENABLE_LEAK_FINDER) + #define XML_LEAK_FINDER + #include "LeakFinder.h" +#endif + + + + + void ShowCrashReport(int) { @@ -27,17 +43,31 @@ void ShowCrashReport(int) exit(-1); } + + + + int main( int argc, char **argv ) { (void)argc; (void)argv; -#ifdef _DEBUG + + #if defined(_MSC_VER) && defined(_DEBUG) && defined(ENABLE_LEAK_FINDER) + InitLeakFinder(); + #endif + + #ifdef _DEBUG _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); -#endif - -#ifndef _DEBUG + + // _X: The simple built-in CRT leak finder - simply break when allocating the Nth block ({N} is listed in the leak output) + // Only useful when the leak is in the same sequence all the time + // _CrtSetBreakAlloc(85950); + + #endif + + #ifndef _DEBUG std::signal(SIGSEGV, ShowCrashReport); -#endif + #endif try { @@ -53,12 +83,17 @@ int main( int argc, char **argv ) LOGERROR("Unknown exception!"); } -#if USE_SQUIRREL + #if USE_SQUIRREL SquirrelVM::Shutdown(); -#endif + #endif -#ifdef _DEBUG - _CrtDumpMemoryLeaks(); -#endif + #if defined(_MSC_VER) && defined(_DEBUG) && defined(ENABLE_LEAK_FINDER) + DeinitLeakFinder(); + #endif + return 0; } + + + + -- cgit v1.2.3