NAME
src/gc/memory.c - Memory allocation
DESCRIPTION
The memory (mem) API handles memory allocation,
Basically just a wrapper around malloc/calloc/realloc/free()
with an setup function to initialize the memory pools.
Functions
void *mem_sys_allocate
Uses void *mem__internal_allocate
Calls void *mem_sys_allocate_zeroed
Uses void *mem__internal_allocate_zeroed
Uses void *mem_sys_realloc
Resizes a chunk of memory.
Unlike void *mem_sys_realloc_zeroed
Resizes a chunk of system memory and fills the newly allocated space with zeroes.
If the pointer is void *mem__internal_realloc
Resizes a chunk of system memory.
Unlike void *mem__internal_realloc_zeroed
Reallocates a given buffer of size void mem_sys_free
Frees a chunk of memory back to the system.
void mem__internal_free
Frees a chunk of memory back to the system.
If void mem_setup_allocator
Initializes the memory allocator and the garbage collection subsystem.
Calls the initialization function associated with each collector,
which is determined at compile time.The "stacktop" parameter is required; it provides an upper bound for stack scanning during a garbage collection run.
malloc
to allocate system memory.
Panics if the system cannot return memory.
malloc
to allocate memory from the system,
Panics if there is no memory available.
If DETAIL_MEMORY_DEBUG
macro is defined,
prints debug information to STDERR
.
calloc
to allocate system memory.
Guaranteed to succeed,
Panics otherwise.
calloc
to allocate system memory.
Guaranteed to succeed,
Panics otherwise.
If DETAIL_MEMORY_DEBUG
macro is defined,
prints debug information to STDERR
.
realloc
,
it can handle a NULL pointer,
in which case it calls calloc
to create the memory block.
NULL
a new memory block is allocated and zeroed instead.
realloc
,
it can handle a NULL pointer,
in which case a new memory block is allocated for the requested size.
If DETAIL_MEMORY_DEBUG
macro is defined,
debug information is printed to STDERR
.
old_size
to size
.
If the new size is larger then the old size,
the difference is filled with zeros.
Contains debugging information,
and can print filename and line number where it is used if DETAIL_MEMORY_DEBUG
is defined.
DETAIL_MEMORY_DEBUG
macro is defined,
prints debug information to STDERR
.