1023 B
1023 B
Heap memory allocations
The Shelter standard library provide a single API for memory allocations on the heap. The heap is only initialized at the end of the memory subsystem and can't be used before. It's not adapted for memory mapped I/O or big buffers allocations (larger than one hundrer pages). The heap internal documentation can be found inside the memory subsystem documentation.
The memory allocations API provide the two following functions (defined inside shelter/lib/include/std/malloc.h and implemented inside shelter/lib/src/std/malloc.c):
void* sh_malloc(sh_uint64 size): allocatesizeamount of bytes. ReturnSH_NULLPTRif an error occured. The heap internal will trigger a heap crash (essentially awhile (SH_TRUE)loop) to prevent any further damage if something very bad happen.void sh_free(void *ptr): free the memory allocated atptr. The heap internal will trigger a heap crash (essentially awhile (SH_TRUE)loop) to prevent any further damage if something very bad happen.