Allocation library

September 1, 2024 ยท View on GitHub

Source: include/stdlib/builtin/alloc.ml

Provides customizable memory allocation utilities.

Macros

MacroDescription
alloc_warnDefault warning for non-gc allocation.
alloc_stopStops the garbage collector.
alloc_start(_lit)Starts the garbage collector, _lit points to the stack bottom.
alloc(_lit)Assigns _lit to an allocated memory block based on its size.
alloc(_lit,_size)Assigns _lit to an allocated memory block of size _size.
alloc_zeroed(_lit)Assigns _lit to an zero-filled allocated memory block based on its size.
alloc_zeroed(_lit, _size)Assigns _lit to an zero-filled allocated memory block of size _size.
dealloc(_lit)Deallocates the memory block pointed by _lit and assigns _lit to null.
with(_lit,_body)Creates a block in which _lit is allocated, used by _body, then deallocated.

Functions

FunctionDescription
alloc_sizeAllocates a memory block of the given size, filled based the fill flag.

Warnings

Warning

Memory allocated by the alloc utilites use different allocators than the one provided by the c standard library. Thus, calling free on a memory address allocated by alloc causes undefined behaviour.