SCM maintains a count of bytes allocated using malloc, and calls the
garbage collector when that number exceeds a dynamically managed limit.
In order for this to work properly,
not be called directly to manage memory freeable by garbage collection.
The following functions are provided for that purpose:
len is the number of bytes that should be allocated, what is a string to be used in error or gc messages.
must_mallocreturns a pointer to newly allocated memory.
must_malloc_cellreturns a newly allocated cell whose
caris c and whose
cdris a pointer to newly allocated memory.
must_realloc_celltakes as argument z a cell whose
cdrshould be a pointer to a block of memory of length olen allocated with
must_malloc_celland modifies the
cdrto point to a block of memory of length len.
must_realloctakes as argument where the address of a block of memory of length olen allocated by
must_mallocand returns the address of a block of length len.
The contents of the reallocated block will be unchanged up to the minimum of the old and new sizes.
what is a pointer to a string used for error and gc messages.
must_realloc_cell must be called with interrupts deferred
not be called during initialization (non-zero errjmp_bad) – the initial
allocations must be large enough.
must_freeis used to free a block of memory allocated by the above functions and pointed to by ptr. len is the length of the block in bytes, but this value is used only for debugging purposes. If it is difficult or expensive to calculate then zero may be used instead.