37 #ifndef NVWA_DEBUG_NEW_H 38 #define NVWA_DEBUG_NEW_H 46 void*
operator new(
size_t size,
const char* file,
int line);
47 void*
operator new[](
size_t size,
const char* file,
int line);
48 void operator delete(
void* ptr,
const char* file,
int line) _NOEXCEPT;
49 void operator delete[](
void* ptr,
const char* file,
int line) _NOEXCEPT;
77 #ifndef _DEBUG_NEW_REDEFINE_NEW 78 #define _DEBUG_NEW_REDEFINE_NEW 1 92 #ifndef _DEBUG_NEW_TYPE 93 #define _DEBUG_NEW_TYPE 1 118 void* addr,
void** stacktrace);
140 # if _DEBUG_NEW_TYPE == 1 141 # define DEBUG_NEW NVWA::debug_new_recorder(__FILE__, __LINE__) ->* new 143 # define DEBUG_NEW new(__FILE__, __LINE__) 146 # if _DEBUG_NEW_REDEFINE_NEW 147 # define new DEBUG_NEW 149 # ifdef _DEBUG_NEW_EMULATE_MALLOC 152 # define malloc(s) ((void*)(new char[s])) 154 # define malloc(s) ((void*)(DEBUG_NEW char[s])) 156 # define free(p) delete[] (char*)(p) 168 void _M_process(
void* ptr);
175 : _M_file(file), _M_line(line) {}
182 template <
class _Tp> _Tp* operator->*(_Tp* ptr)
183 { _M_process(ptr);
return ptr; }
207 #endif // NVWA_DEBUG_NEW_H Recorder class to remember the call context.
Definition: debug_new.h:164
int check_leaks()
Checks for memory leaks.
Definition: debug_new.cpp:761
bool new_autocheck_flag
Flag to control whether nvwa::check_leaks will be automatically called on program exit...
Definition: debug_new.cpp:325
stacktrace_print_callback_t stacktrace_print_callback
Pointer to the callback used to print the stack backtrace in case of a memory problem.
Definition: debug_new.cpp:354
int check_mem_corruption()
Checks for heap corruption.
Definition: debug_new.cpp:836
static debug_new_counter __debug_new_count
Counting object for each file including debug_new.h.
Definition: debug_new.h:203
Counter class for on-exit leakage check.
Definition: debug_new.h:195
const char * new_progname
Pointer to the program name.
Definition: debug_new.cpp:347
debug_new_recorder(const char *file, int line)
Constructor to remember the call context.
Definition: debug_new.h:174
leak_whitelist_callback_t leak_whitelist_callback
Pointer to the callback used to filter out false positives from leak reports.
Definition: debug_new.cpp:360
bool new_verbose_flag
Flag to control whether verbose messages are output.
Definition: debug_new.cpp:330
C++11 feature detection macros and workarounds.
static int _S_count
Count of source files that use debug_new.
Definition: debug_new.h:197
void(* stacktrace_print_callback_t)(FILE *fp, void **stacktrace)
Callback type for stack trace printing.
Definition: debug_new.h:102
Common definitions for preprocessing.
FILE * new_output_fp
Pointer to the output stream.
Definition: debug_new.cpp:337
bool(* leak_whitelist_callback_t)(char const *file, int line, void *addr, void **stacktrace)
Callback type for the leak whitelist function.
Definition: debug_new.h:117