diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-13 22:47:03 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-13 22:47:03 +0100 |
commit | 4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c (patch) | |
tree | febea3ecd89c0d4aa83924e430bf11366d754733 /source/main.cpp | |
parent | New makefile with automatic *.cpp sourcefile import, automatic header file dependencies and switchable debug / release configuration. gnumake-specific :( (diff) | |
download | cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.gz cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.bz2 cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.lz cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.xz cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.zst cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.zip |
Diffstat (limited to '')
-rw-r--r-- | source/main.cpp | 55 |
1 files changed, 45 insertions, 10 deletions
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;
}
+
+
+
+
|