#include <new>#include <stdio.h>Go to the source code of this file.
Classes | |
| class | __debug_new_counter |
| Part of Wu Yongwei's new/delete debug memory leak detector. More... | |
Macros | |
| #define | HAS_PLACEMENT_DELETE 1 |
| #define | _DEBUG_NEW_REDEFINE_NEW 1 |
| #define | DEBUG_NEW new(__FILE__, __LINE__) |
| #define | new DEBUG_NEW |
Functions | |
| int | check_leaks () |
| void * | operator new (size_t size, const char *file, int line) |
| void * | operator new[] (size_t size, const char *file, int line) |
| void | operator delete (void *pointer, const char *file, int line) throw () |
| void | operator delete[] (void *pointer, const char *file, int line) throw () |
Variables | |
| bool | new_autocheck_flag |
| bool | new_verbose_flag |
| FILE * | new_output_fp |
| const char * | new_progname |
Header file for checking leaks caused by unmatched new/delete.
Definition in file debug_new.h.
| #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:
Definition at line 92 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 124 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 64 of file debug_new.h.
| #define new DEBUG_NEW |
Definition at line 127 of file debug_new.h.
| int check_leaks | ( | ) |
Checks for memory leaks.
Definition at line 497 of file debug_new.cc.
References _DEBUG_NEW_HASHTABLESIZE.
Referenced by internal_w(), and __debug_new_counter::~__debug_new_counter().
| 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 | ||
| ) |
Definition at line 525 of file debug_new.cc.
References _DEBUG_NEW_ALIGNMENT, aligned_list_item_size, and STATIC_ASSERT.
| void* operator new[] | ( | size_t | size, |
| const char * | file, | ||
| int | line | ||
| ) |
Definition at line 592 of file debug_new.cc.
References aligned_list_item_size, and new_ptr_list_t::line.
| bool new_autocheck_flag |
Flag to control whether check_leaks will be automatically called on program exit.
Definition at line 261 of file debug_new.cc.
Referenced by __debug_new_counter::~__debug_new_counter().
| FILE* new_output_fp |
Pointer to the output stream. The default output is stderr, and one may change it to a user stream if needed (say, new_verbose_flag is true and there are a lot of (de)allocations).
Definition at line 273 of file debug_new.cc.
Referenced by __debug_new_counter::~__debug_new_counter().
| const char* new_progname |
Pointer to the program name. Its initial value is the macro _DEBUG_NEW_PROGNAME. You should try to assign the program path to it early in your application. Assigning argv[0] to it in main is one way. If you use bash or ksh (or similar), the following statement is probably what you want: ‘new_progname = getenv("_");’.
Definition at line 283 of file debug_new.cc.
| bool new_verbose_flag |
Flag to control whether verbose messages are output.
Definition at line 266 of file debug_new.cc.
Referenced by __debug_new_counter::~__debug_new_counter().
1.8.17