typedef struct BinBin;
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
binalloc are added to the
Bin pointed to by
bp. All items in a bin may be freed with one call to
binfree; there is no way to free a single item.
Binalloc 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
binalloc will have the same value.
binalloc(0) returns a valid pointer rather than null.
clr is non-zero, the allocated memory is set to 0;
otherwise, the contents are undefined.
Bingrow is used to extend the size of a block of memory returned by
Bp must point to the same bin group used to allocate the original block,
osize must be the last size used to allocate or grow the block.
A pointer to a block of at least
size bytes is returned, with the same contents in the first
clr is non-zero, the remaining bytes are set to 0,
and are undefined otherwise.
nil, it and
osize are ignored, and the result is the same as calling
bingrow allocate large chunks of memory using
and return pieces of these chunks.
The chunks are
freed upon a call to