From 603337af8f1a9c5934dbbf29c82b34250b1fcb17 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sun, 4 Feb 2001 12:16:07 +0000 Subject: [PATCH] regex: added VC6 debugging/memory tracking support to regression test program [SVN r8913] --- demo/regress/regress.cpp | 18 +++++++++++++++--- demo/regress/regress.h | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/demo/regress/regress.cpp b/demo/regress/regress.cpp index a8449380..96fa502b 100644 --- a/demo/regress/regress.cpp +++ b/demo/regress/regress.cpp @@ -41,6 +41,10 @@ using std::endl; #include "regress.h" +#if defined(BOOST_MSVC) && defined(_DEBUG) +#include +#endif + // // declare all our globals here: @@ -70,6 +74,13 @@ void usage() int main(int argc, char * argv[]) { +#if defined(BOOST_MSVC) && defined(_DEBUG) + // turn on heap reporting at program exit: + int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); + tmpFlag |= _CRTDBG_LEAK_CHECK_DF; + tmpFlag &= ~_CRTDBG_CHECK_CRT_DF; + _CrtSetDbgFlag( tmpFlag ); +#endif if(argc < 2) usage(); int i; @@ -100,6 +111,7 @@ int main(int argc, char * argv[]) } cout << line << " lines, " << tests << " tests completed in file " << argv[i] << endl; } + return error_count; } @@ -192,7 +204,7 @@ jm_debug_alloc::jm_debug_alloc(const jm_debug_alloc& d) } jm_debug_alloc& jm_debug_alloc::operator=(const jm_debug_alloc& d) { - free(); + free_(); blocks = d.blocks; count = d.count; ++(*count); @@ -207,11 +219,11 @@ jm_debug_alloc::~jm_debug_alloc() } else { - free(); + free_(); guard = 0; } } -void jm_debug_alloc::free() +void jm_debug_alloc::free_() { if(--(*count) == 0) { diff --git a/demo/regress/regress.h b/demo/regress/regress.h index a1a5b869..14a2389b 100644 --- a/demo/regress/regress.h +++ b/demo/regress/regress.h @@ -137,7 +137,7 @@ public: jm_debug_alloc& operator=(const jm_debug_alloc& d); ~jm_debug_alloc(); - void free(); + void free_(); static pointer address(reference x) { return &x;