binalloc, bingrow, binfree – grouped memory allocation
typedef struct Bin Bin;
void *binalloc(Bin **bp, ulong size, int clr);
void *bingrow(Bin **bp, void *op, ulong osize,
ulong size, int clr);
void binfree(Bin **bp);
These routines provide simple grouped memory allocation and deallocation.
Items allocated with
are added to the
pointed to by
All items in a bin may be freed with one call to
there is no way to free a single item.
returns a pointer to a new block of at least
The block is suitably aligned for storage of any type of object.
No two active pointers from
will have the same value.
returns a valid pointer rather than null.
is non-zero, the allocated memory is set to 0;
otherwise, the contents are undefined.
is used to extend the size of a block of memory returned by
must point to the same bin group used to allocate the original block,
must be the last size used to allocate or grow the block.
A pointer to a block of at least
bytes is returned, with the same contents in the first
is non-zero, the remaining bytes are set to 0,
and are undefined otherwise.
are ignored, and the result is the same as calling
allocate large chunks of memory using
and return pieces of these chunks.
The chunks are
upon a call to
return 0 if there is no available memory.