debug_new.h File Reference


Detailed Description

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

Version:
3.4, 2005/09/13
Author:
Wu Yongwei

Definition in file debug_new.h.

#include <new>
#include <stdio.h>

Go to the source code of this file.

Data Structures

class  __debug_new_counter

Defines

#define _DEBUG_NEW_REDEFINE_NEW   1
#define DEBUG_NEW   new(__FILE__, __LINE__)
#define HAS_PLACEMENT_DELETE   1
#define new   DEBUG_NEW

Functions

int check_leaks ()
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


Define 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, to call operator new directly, or to call placement new, 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 85 of file debug_new.h.

#define DEBUG_NEW   new(__FILE__, __LINE__)

The macro to catch file/line information on allocation. If _DEBUG_NEW_REDEFINE_NEW is not defined, 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 HAS_PLACEMENT_DELETE   1

Macro to indicate whether placement delete operators are supported on a certain compiler. Some compilers, like Borland C++ Compiler 5.5.1 and Digital Mars Compiler 8.42, do not support them, and the user must define this macro to 0 to make the program compile. Also note that in that case memory leakage will occur if an exception is thrown in the initialization (constructor) of a dynamically created object.

Definition at line 57 of file debug_new.h.

#define new   DEBUG_NEW

Definition at line 120 of file debug_new.h.


Function Documentation

int check_leaks (  ) 

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

Counting object for each file including debug_new.h.

Definition at line 141 of file debug_new.h.

const char* new_progname


Generated on Wed May 5 00:06:37 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6