SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
debug_new.h File Reference
#include <new>
#include <stdio.h>

Go to the source code of this file.

Data Structures

class  __debug_new_counter
 
class  __debug_new_recorder
 

Macros

#define _DEBUG_NEW_REDEFINE_NEW   1
 
#define _DEBUG_NEW_TYPE   1
 
#define DEBUG_NEW   __debug_new_recorder(__FILE__, __LINE__) ->* new
 
#define new   DEBUG_NEW
 

Functions

int check_leaks ()
 
int check_mem_corruption ()
 
void operator delete (void *pointer, const char *file, int line) throw ()
 
void operator delete[] (void *pointer, const char *file, int line) throw ()
 
void * operator new (size_t size, const char *file, int line)
 
void * operator new[] (size_t size, const char *file, int line)
 

Variables

static __debug_new_counter __debug_new_count
 
bool new_autocheck_flag
 
FILE * new_output_fp
 
const char * new_progname
 
bool new_verbose_flag
 

Detailed Description

Header file for checking leaks caused by unmatched new/delete.

Version
4.7, 2010/01/08
Author
Wu Yongwei

Definition in file debug_new.h.

Macro Definition Documentation

#define _DEBUG_NEW_REDEFINE_NEW   1

Macro to indicate whether redefinition of new is wanted. If one wants to define one's own operator new, or to call operator new directly, it should be defined to 0 to alter the default behaviour. Unless, of course, one is willing to take the trouble to write something like:

# ifdef new
# define _NEW_REDEFINED
# undef new
# endif
// Code that uses new is here
# ifdef _NEW_REDEFINED
# ifdef DEBUG_NEW
# define new DEBUG_NEW
# endif
# undef _NEW_REDEFINED
# endif

Definition at line 70 of file debug_new.h.

#define _DEBUG_NEW_TYPE   1

Macro to indicate which variant of DEBUG_NEW is wanted. The default value 1 allows the use of placement new (like new(std::nothrow)), but the verbose output (when new_verbose_flag is true) looks worse than some older versions (no file/line information for allocations). Define it to 2 to revert to the old behaviour that records file and line information directly on the call to operator new.

Definition at line 85 of file debug_new.h.

#define DEBUG_NEW   __debug_new_recorder(__FILE__, __LINE__) ->* new

Macro to catch file/line information on allocation. If _DEBUG_NEW_REDEFINE_NEW is 0, one can use this macro directly; otherwise new will be defined to it, and one must use new instead.

Definition at line 117 of file debug_new.h.

#define new   DEBUG_NEW

Definition at line 123 of file debug_new.h.

Function Documentation

int check_leaks ( )
int check_mem_corruption ( )
void operator delete ( void *  pointer,
const char *  file,
int  line 
)
throw (
)
void operator delete[] ( void *  pointer,
const char *  file,
int  line 
)
throw (
)
void* operator new ( size_t  size,
const char *  file,
int  line 
)
void* operator new[] ( size_t  size,
const char *  file,
int  line 
)

Variable Documentation

__debug_new_counter __debug_new_count
static

Counting object for each file including debug_new.h.

Definition at line 179 of file debug_new.h.

bool new_autocheck_flag
FILE* new_output_fp
const char* new_progname
bool new_verbose_flag