Recorder class to remember the call context.
The idea comes from Greg Herlihy's post in comp.lang.c++.moderated.
Definition at line 164 of file debug_new.h.
void debug_new_recorder::_M_process |
( |
void * |
usr_ptr | ) |
|
|
private |
Processes the allocated memory and inserts file/line informatin. It will only be done when it can ensure the memory is allocated by one of our operator new variants.
- Parameters
-
usr_ptr | pointer returned by a new-expression |
Definition at line 904 of file debug_new.cpp.
912 size_t offset = (
char*)usr_ptr - (
char*)
_NULLPTR;
913 if (offset % PLATFORM_MEM_ALIGNMENT != 0) {
914 offset -=
sizeof(size_t);
915 if (offset % PLATFORM_MEM_ALIGNMENT != 0) {
918 "warning: memory unaligned; skipping processing (%s:%d)\n",
922 usr_ptr = (
char*)usr_ptr -
sizeof(
size_t);
931 "warning: debug_new used with placement new (%s:%d)\n",
938 "info: pointer %p allocated from %s:%d\n",
941 #if _DEBUG_NEW_FILENAME_LEN == 0
948 #if _DEBUG_NEW_REMEMBER_STACK_TRACE == 2
949 free(ptr->stacktrace);
static fast_mutex new_output_lock
static const unsigned DEBUG_NEW_MAGIC
#define _DEBUG_NEW_FILENAME_LEN
static const int ALIGNED_LIST_ITEM_SIZE
char file[44]
File name of the caller.
unsigned magic
Magic number for error detection.
unsigned line
Line number of the caller; or 0.
References _DEBUG_NEW_FILENAME_LEN, _M_file, _M_line, _NULLPTR, ALIGNED_LIST_ITEM_SIZE, DEBUG_NEW_MAGIC, new_ptr_list_t::file, new_ptr_list_t::line, new_ptr_list_t::magic, new_output_fp, new_output_lock, and new_verbose_flag.
Referenced by operator->*().