RBucket implements an even faster memory allocator than rchunk(3) .
This one uses a structure RBucket to contain the pool of memory
from which it allocates and frees. Unlike rchunk(3) , rbucket does
not perform any thread locking, and only allocates chunks of sizes
as specified by rbucket_new(3) .
As rbucket does not perform thread locking, it is generally expected that
rbucket will be used per-thread, or the user will have to do the locking.
See rthread(3) for details on roy threading, and rthread_mutex(3) for
mutexes in particular.
The speed achieved by rbucket is almost that of using alloca(3) , but is
safe for use on all platforms.
rbucket_new(3) creates a new bucket that will allow you to allocate
size sized blocks of memory from it.
rbucket_destroy(3) frees the RBucket structure and ALL memory used
in ALL blocks allocated from this bucket. Blocks allocated with
rbucket_alloc(3) are freed along with those still in the bucket.
Again, ALL memory used by the bucket is freed, whether allocated
or not.
rbucket_empty(3) frees all blocks in bucket, both those in use
and not in use, but does not destroy the RBucket structure itself
so that it can continue to be used.
rbucket_alloc(3) allocates a block from bucket. This returns
a newly allocated block of memory of the size specified in
rbucket_new(3) .
rbucket_free(3) returns the block of memory mem back to the
bucket. It will then be made available for future allocations
with rbucket_alloc(3) .
MACROS
rbucket_alloc, rbucket_alloc0, and rbucket_free are implemented as macros,
though there should never be a problem with their behavior if used as
functions.