parrotcode: Memory allocation | |
Contents | C |
src/gc/memory.c - Memory allocation
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.
void *mem_sys_allocate
malloc
to allocate system memory.
Panics if the system cannot return memory.void *mem__internal_allocate
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
.void *mem_sys_allocate_zeroed
calloc
to allocate system memory.
Guaranteed to succeed,
Panics otherwise.void *mem__internal_allocate_zeroed
calloc
to allocate system memory.
Guaranteed to succeed,
Panics otherwise.
If DETAIL_MEMORY_DEBUG
macro is defined,
prints debug information to STDERR
.void *mem_sys_realloc
realloc
,
it can handle a NULL pointer,
in which case it calls calloc
to create the memory block.void *mem_sys_realloc_zeroed
NULL
a new memory block is allocated and zeroed instead.void *mem__internal_realloc
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
.void *mem__internal_realloc_zeroed
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.void mem_sys_free
void mem__internal_free
DETAIL_MEMORY_DEBUG
macro is defined,
prints debug information to STDERR
.void mem_setup_allocator
|