|
Barrelfish
|
Simple heap allocator. More...
Functions | |
| void | heap_init (struct heap *heap, void *buf, size_t buflen, Morecore_func_t morecore_func) |
| Initialise a new heap. More... | |
| void * | heap_alloc (struct heap *heap, size_t nbytes) |
| Equivalent of malloc; allocates memory out of given heap. More... | |
| void | heap_free (struct heap *heap, void *ap) |
| Equivalent of free: put block back in free list. | |
| union heap_header * | heap_default_morecore (struct heap *heap, unsigned nu) |
| sbrk() equivalent. More... | |
Simple heap allocator.
This file implements a very simple heap allocator, based on K&R malloc.
| void* heap_alloc | ( | struct heap * | heap, |
| size_t | nbytes | ||
| ) |
Equivalent of malloc; allocates memory out of given heap.
| union heap_header* heap_default_morecore | ( | struct heap * | heap, |
| unsigned | nu | ||
| ) |
sbrk() equivalent.
This function allocates at least the amount given by 'nu' in sizeof(::Header) byte units. It returns a pointer to the freelist header of the memory region. NULL is returned when out of memory.
| nu | Number of memory units (1 unit == sizeof(::Header) bytes) |
| void heap_init | ( | struct heap * | heap, |
| void * | buf, | ||
| size_t | buflen, | ||
| Morecore_func_t | morecore_func | ||
| ) |
Initialise a new heap.
| heap | Heap structure to be filled in |
| buf | Memory buffer out of which to allocate |
| buflen | Size of buffer |
| morecore_func | Function to call to increase heap, or NULL |
1.8.11