Skip to main content

GC_debug_malloc_replacement

Function GC_debug_malloc_replacement 

Source
pub unsafe extern "C" fn GC_debug_malloc_replacement(
    arg1: usize,
) -> *mut c_void
Expand description

The functions that allocate objects with debug information (like the above), but just fill in dummy file and line number information. Thus they can serve as drop-in malloc/realloc/reallocf replacements. This can be useful for two reasons:

  1. It allows the collector to be built with DBG_HDRS_ALL macro defined even if some allocation calls come from 3rd-party libraries that cannot be recompiled.
  2. On some platforms, the file and line information is redundant, since it can be reconstructed from a stack trace. On such platforms it may be more convenient not to recompile, e.g. for leak detection. This can be accomplished by instructing the linker to replace malloc/realloc/reallocf with these.

Note that these functions (for a nonzero new size in case of realloc and reallocf) are guaranteed never to return NULL unless GC_oom_fn() returns NULL.