|
microlisp 0.1.0
A small Scheme-subset interpreter in modern C.
|
Caller-supplied allocator. More...
#include <microlisp.h>
Data Fields | |
| void *(* | alloc )(size_t size, void *user) |
Allocate size bytes. | |
| void(* | free )(void *ptr, void *user) |
Free a pointer previously returned by alloc. | |
| void * | user |
Opaque user data passed verbatim to alloc and free. | |
Caller-supplied allocator.
Pass NULL to microlisp_state_create to use the platform malloc / free.
The implementation only calls alloc and free; it does not call realloc, calloc, or memalign.
alloc / free functions must| void *(* microlisp_allocator::alloc) (size_t size, void *user) |
Allocate size bytes.
Returns NULL on failure. Must be non-NULL whenever the surrounding microlisp_allocator struct is non-NULL.
Alignment contract: every returned non-NULL pointer must be aligned to at least 8 bytes (alignof(uint64_t)). The interpreter's value representation reserves the low 3 bits of heap-object pointers for a type tag; allocators that return weaker alignment (1- or 4-byte) will silently corrupt values on the first GC cycle. Platform malloc always meets this on any supported target; custom arenas must round up explicitly.
| void(* microlisp_allocator::free) (void *ptr, void *user) |
Free a pointer previously returned by alloc.
Must be non-NULL whenever the surrounding microlisp_allocator struct is non-NULL. free(NULL) is a no-op.
| void* microlisp_allocator::user |
Opaque user data passed verbatim to alloc and free.