Header file for checking leaks caused by unmatched new/delete. More...
#include <new>#include <stdio.h>#include "_nvwa.h"#include "c++11.h"

Go to the source code of this file.
Classes | |
| class | nvwa::debug_new_recorder |
| Recorder class to remember the call context. More... | |
| class | nvwa::debug_new_counter |
| Counter class for on-exit leakage check. More... | |
Namespaces | |
| namespace | nvwa |
Defines | |
| #define | _DEBUG_NEW_TYPE 1 |
| Macro to indicate which variant of DEBUG_NEW is wanted. | |
| #define | DEBUG_NEW NVWA::debug_new_recorder(__FILE__, __LINE__) ->* new |
| Macro to catch file/line information on allocation. | |
Functions | |
| void * | operator new (size_t size, const char *file, int line) |
| Allocates memory with file/line information. | |
| void * | operator new[] (size_t size, const char *file, int line) |
| Allocates array memory with file/line information. | |
| void | operator delete (void *ptr, const char *file, int line) noexcept |
| Placement deallocation function. | |
| void | operator delete[] (void *ptr, const char *file, int line) noexcept |
| Placement deallocation function. | |
| int | nvwa::check_leaks () |
| Checks for memory leaks. | |
| int | nvwa::check_mem_corruption () |
| Checks for heap corruption. | |
Variables | |
| bool | nvwa::new_autocheck_flag = true |
| Flag to control whether check_leaks will be automatically called on program exit. | |
| bool | nvwa::new_verbose_flag = false |
| Flag to control whether verbose messages are output. | |
| FILE * | nvwa::new_output_fp = stderr |
| Pointer to the output stream. | |
| const char * | nvwa::new_progname = _DEBUG_NEW_PROGNAME |
| Pointer to the program name. | |
Header file for checking leaks caused by unmatched new/delete.
| #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 nvwa::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.
| #define DEBUG_NEW NVWA::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.
| void operator delete | ( | void * | ptr, | |
| const char * | file, | |||
| int | line | |||
| ) |
Placement deallocation function.
For details, please check Section 5.3.4 of the C++ 1998 or 2011 Standard.
| ptr | pointer to the previously allocated memory | |
| file | null-terminated string of the file name | |
| line | line number |
| void operator delete[] | ( | void * | ptr, | |
| const char * | file, | |||
| int | line | |||
| ) |
Placement deallocation function.
For details, please check Section 5.3.4 of the C++ 1998 or 2011 Standard.
| ptr | pointer to the previously allocated memory | |
| file | null-terminated string of the file name | |
| line | line number |
| void* operator new | ( | size_t | size, | |
| const char * | file, | |||
| int | line | |||
| ) |
Allocates memory with file/line information.
| size | size of the required memory block | |
| file | null-terminated string of the file name | |
| line | line number |
NULL if memory is insufficient (_DEBUG_NEW_STD_OPER_NEW is 0) | bad_alloc | memory is insufficient (_DEBUG_NEW_STD_OPER_NEW is 1) |
| void* operator new[] | ( | size_t | size, | |
| const char * | file, | |||
| int | line | |||
| ) |
Allocates array memory with file/line information.
| size | size of the required memory block | |
| file | null-terminated string of the file name | |
| line | line number |
NULL if memory is insufficient (_DEBUG_NEW_STD_OPER_NEW is 0) | bad_alloc | memory is insufficient (_DEBUG_NEW_STD_OPER_NEW is 1) |
1.6.2