Barrelfish
|
Simple slab allocator. More...
Functions | |
void | slab_init (struct slab_allocator *slabs, size_t blocksize, slab_refill_func_t refill_func) |
Initialise a new slab allocator. More... | |
void | slab_grow (struct slab_allocator *slabs, void *buf, size_t buflen) |
Add memory (a new slab) to a slab allocator. More... | |
void * | slab_alloc (struct slab_allocator *slabs) |
Allocate a new block from the slab allocator. More... | |
void | slab_free (struct slab_allocator *slabs, void *block) |
Free a block to the slab allocator. More... | |
size_t | slab_freecount (struct slab_allocator *slabs) |
Returns the count of free blocks in the allocator. More... | |
errval_t | slab_default_refill (struct slab_allocator *slabs) |
General-purpose implementation of a slab allocate/refill function. More... | |
Simple slab allocator.
This file implements a simple slab allocator. It allocates blocks of a fixed size from a pool of contiguous memory regions ("slabs").
void* slab_alloc | ( | struct slab_allocator * | slabs | ) |
Allocate a new block from the slab allocator.
slabs | Pointer to slab allocator instance |
errval_t slab_default_refill | ( | struct slab_allocator * | slabs | ) |
General-purpose implementation of a slab allocate/refill function.
Allocates and maps a single page (FIXME: make configurable) and adds it to the allocator.
slabs | Pointer to slab allocator instance |
void slab_free | ( | struct slab_allocator * | slabs, |
void * | block | ||
) |
Free a block to the slab allocator.
slabs | Pointer to slab allocator instance |
block | Pointer to block previously returned by slab_alloc |
size_t slab_freecount | ( | struct slab_allocator * | slabs | ) |
Returns the count of free blocks in the allocator.
slabs | Pointer to slab allocator instance |
void slab_grow | ( | struct slab_allocator * | slabs, |
void * | buf, | ||
size_t | buflen | ||
) |
Add memory (a new slab) to a slab allocator.
slabs | Pointer to slab allocator instance |
buf | Pointer to start of memory region |
buflen | Size of memory region (in bytes) |
void slab_init | ( | struct slab_allocator * | slabs, |
size_t | blocksize, | ||
slab_refill_func_t | refill_func | ||
) |
Initialise a new slab allocator.
slabs | Pointer to slab allocator instance, to be filled-in |
blocksize | Size of blocks to be allocated by this allocator |
refill_func | Pointer to function to call when out of memory (or NULL) |