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 malloc to allocate system memory. Panics if the system cannot return memory.

void *mem__internal_allocate

Calls 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

Uses calloc to allocate system memory. Guaranteed to succeed, Panics otherwise.

void *mem__internal_allocate_zeroed

Uses 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

Resizes a chunk of memory. Unlike realloc, it can handle a NULL pointer, in which case it calls calloc to create the memory block.

void *mem_sys_realloc_zeroed

Resizes a chunk of system memory and fills the newly allocated space with zeroes. If the pointer is NULL a new memory block is allocated and zeroed instead.

void *mem__internal_realloc

Resizes a chunk of system memory. Unlike 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

Reallocates a given buffer of size 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

Frees a chunk of memory back to the system.

void mem__internal_free

Frees a chunk of memory back to the system. If DETAIL_MEMORY_DEBUG macro is defined, prints debug information to STDERR.

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.


parrot