From e3974c112ed0e85c719ec89a11b31f9f733e8f8e Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Sun, 30 Jun 2013 07:49:30 -0700 Subject: [PATCH] Default MSVC CRT Debug heap leak checks to ON --- .../modules/beast_core/diagnostic/beast_Debug.cpp | 14 ++++++++++++++ .../beast_core/native/beast_win32_SystemStats.cpp | 12 ------------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Subtrees/beast/modules/beast_core/diagnostic/beast_Debug.cpp b/Subtrees/beast/modules/beast_core/diagnostic/beast_Debug.cpp index d8e1245d43..e52ea11a67 100644 --- a/Subtrees/beast/modules/beast_core/diagnostic/beast_Debug.cpp +++ b/Subtrees/beast/modules/beast_core/diagnostic/beast_Debug.cpp @@ -36,6 +36,20 @@ void breakPoint () #if BEAST_MSVC && defined (_DEBUG) +#if BEAST_CHECK_MEMORY_LEAKS +struct DebugFlagsInitialiser +{ + DebugFlagsInitialiser() + { + // Activate leak checks on exit in the MSVC Debug CRT (C Runtime) + // + _CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); + } +}; + +static DebugFlagsInitialiser debugFlagsInitialiser; +#endif + void setAlwaysCheckHeap (bool bAlwaysCheck) { int flags = _CrtSetDbgFlag (_CRTDBG_REPORT_FLAG); diff --git a/Subtrees/beast/modules/beast_core/native/beast_win32_SystemStats.cpp b/Subtrees/beast/modules/beast_core/native/beast_win32_SystemStats.cpp index f6568e1bd9..368924184d 100644 --- a/Subtrees/beast/modules/beast_core/native/beast_win32_SystemStats.cpp +++ b/Subtrees/beast/modules/beast_core/native/beast_win32_SystemStats.cpp @@ -115,18 +115,6 @@ SystemStats::CPUFlags::CPUFlags() numCpus = (int) systemInfo.dwNumberOfProcessors; } -#if BEAST_MSVC && BEAST_CHECK_MEMORY_LEAKS -struct DebugFlagsInitialiser -{ - DebugFlagsInitialiser() - { - _CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); - } -}; - -static DebugFlagsInitialiser debugFlagsInitialiser; -#endif - //============================================================================== SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() {