1.3 AllocationΒΆ
Functions or objects that allocate memory take a pointer to a ZixAllocator
,
which can be used to customize the allocation scheme.
To simply use the system allocator,
callers can pass NULL
,
which is equivalent to zix_default_allocator()
.
Zix includes one implementation of a custom allocator,
a very simple bump-pointer allocator which can be created with zix_bump_allocator()
.
A convenience API for using a custom allocator if provided
(and the system allocator otherwise)
is provided with functions like zix_malloc()
that correspond to those in the standard C API.
Memory allocated with an allocator must be freed by calling zix_free()
with the same allocator.