Enable memory leak detection

This was SVN commit r517.
This commit is contained in:
Ykkrosh 2004-06-15 21:08:51 +00:00
parent ea68626ec1
commit 0d7f2501f9
2 changed files with 13 additions and 5 deletions

View File

@ -31,6 +31,7 @@
#include <string>
#include <set>
#include <deque>
#include <fstream>
#include <functional>
#include <algorithm>
@ -52,7 +53,10 @@
#include <xercesc/framework/LocalFileInputSource.hpp>
// Nicer memory leak reporting in MSVC
// (except you've got to include all STL headers first to avoid
// nasty complaints, so make sure they're in the list above)
#include <crtdbg.h>
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
#endif

View File

@ -199,13 +199,17 @@ static inline void pre_libc_init()
static inline void pre_main_init()
{
#ifndef NDEBUG
uint flags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
// Always enable leak detection in debug builds
flags |= _CRTDBG_LEAK_CHECK_DF;
#ifdef PARANOIA
// force malloc et al. to check the heap every call.
// slower, but reports errors closer to where they occur.
uint flags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
flags |= _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_DELAY_FREE_MEM_DF;
#endif // PARANOIA
_CrtSetDbgFlag(flags);
#endif
#endif // !NDEBUG
call_func_tbl(init_begin, init_end);