summaryrefslogtreecommitdiff
path: root/zen/debug_memory_leaks.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zen/debug_memory_leaks.cpp')
-rw-r--r--zen/debug_memory_leaks.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/zen/debug_memory_leaks.cpp b/zen/debug_memory_leaks.cpp
new file mode 100644
index 00000000..8774d16f
--- /dev/null
+++ b/zen/debug_memory_leaks.cpp
@@ -0,0 +1,31 @@
+// **************************************************************************
+// * This file is part of the FreeFileSync project. It is distributed under *
+// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
+// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved *
+// **************************************************************************
+
+//-----------Memory Leak Detection--------------------------
+//Usage: just include this file into a Visual Studio project
+
+
+#ifndef NDEBUG
+#define _CRTDBG_MAP_ALLOC //
+#include <stdlib.h> //keep this order: "The #include statements must be in the order shown here. If you change the order, the functions you use may not work properly."
+#include <crtdbg.h> //overwrites "operator new" ect; no need to include this in every compilation unit!
+//http://msdn.microsoft.com/en-us/library/e5ewb1h3(v=vs.80).aspx
+
+namespace
+{
+struct OnStartup
+{
+ OnStartup()
+ {
+ //note: wxWidgets also "activates" leak detection in the usual buggy way: it sets incomplete flags and incorrectly overwrites them rather than appending -> luckily it still seems to work!
+ int flags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
+ flags |= _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF;
+ _CrtSetDbgFlag(flags);
+ }
+
+} dummy;
+}
+#endif \ No newline at end of file
bgstack15