regex: added VC6 debugging/memory tracking support to regression test program

[SVN r8913]
This commit is contained in:
John Maddock
2001-02-04 12:16:07 +00:00
parent 47f5cc6fa1
commit 603337af8f
2 changed files with 16 additions and 4 deletions

View File

@ -41,6 +41,10 @@ using std::endl;
#include "regress.h" #include "regress.h"
#if defined(BOOST_MSVC) && defined(_DEBUG)
#include <CRTDBG.H>
#endif
// //
// declare all our globals here: // declare all our globals here:
@ -70,6 +74,13 @@ void usage()
int main(int argc, char * argv[]) 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) if(argc < 2)
usage(); usage();
int i; int i;
@ -100,6 +111,7 @@ int main(int argc, char * argv[])
} }
cout << line << " lines, " << tests << " tests completed in file " << argv[i] << endl; cout << line << " lines, " << tests << " tests completed in file " << argv[i] << endl;
} }
return error_count; 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) jm_debug_alloc& jm_debug_alloc::operator=(const jm_debug_alloc& d)
{ {
free(); free_();
blocks = d.blocks; blocks = d.blocks;
count = d.count; count = d.count;
++(*count); ++(*count);
@ -207,11 +219,11 @@ jm_debug_alloc::~jm_debug_alloc()
} }
else else
{ {
free(); free_();
guard = 0; guard = 0;
} }
} }
void jm_debug_alloc::free() void jm_debug_alloc::free_()
{ {
if(--(*count) == 0) if(--(*count) == 0)
{ {

View File

@ -137,7 +137,7 @@ public:
jm_debug_alloc& operator=(const jm_debug_alloc& d); jm_debug_alloc& operator=(const jm_debug_alloc& d);
~jm_debug_alloc(); ~jm_debug_alloc();
void free(); void free_();
static pointer address(reference x) static pointer address(reference x)
{ {
return &x; return &x;