Sets up the default allocator (libc pass-through, or the cmocka
test allocator when built with SIG_TEST). Call once before any
other sig_alloc_* function.
Sets up the default allocator (libc pass-through, or the cmocka
test allocator when built with SIG_TEST). Call once before any
other sig_alloc_* function.
Overrides the active allocator. Passing NULL restores the default
chosen by sig_alloc_init(). Any function pointer in `allocator` may
be NULL if that operation is not needed by the caller of this
override (e.g. a test that only exercises sig_alloc()): a NULL
pointer for any operation falls back to the libc implementation for
that operation only, so sig_calloc/sig_realloc/sig_free (and their
SIG_DEBUG counterparts) never dereference a NULL function pointer
even if the override only sets `alloc`.
_sig_alloc_debug
void * _sig_alloc_debug(size_t size, const char * file, int line)
Allocation counters, maintained (atomically) in every build. Counts
only successful calls: sig_realloc(NULL, n) is an alloc, a realloc of
an existing block is a realloc (the live block count is unchanged),
and sig_free(NULL) is ignored. Counters restart at sig_alloc_init().
live_bytes needs per-block size tracking, which only a SIG_DEBUG build
has: live_bytes_tracked says whether live_bytes is meaningful.