Xenomai  3.1
Dynamic memory allocation services

This code implements a variant of the allocator described in "Design of a General Purpose Memory Allocator for the 4.3BSD Unix Kernel" by Marshall K. More...

Collaboration diagram for Dynamic memory allocation services:

Functions

void xnheap_destroy (struct xnheap *heap)
 
Destroys a memory heap. More...
 
void * xnheap_alloc (struct xnheap *heap, size_t size)
 
Allocate a memory block from a memory heap. More...
 
void xnheap_free (struct xnheap *heap, void *block)
 
Release a block to a memory heap. More...
 
void xnheap_set_name (struct xnheap *heap, const char *name,...)
 
Set the heap's name string. More...
 

Detailed Description

This code implements a variant of the allocator described in "Design of a General Purpose Memory Allocator for the 4.3BSD Unix Kernel" by Marshall K.

McKusick and Michael J. Karels (USENIX 1988), see http://docs.FreeBSD.org/44doc/papers/kernmalloc.pdf. The free page list is maintained in rbtrees for fast lookups of multi-page memory ranges, and pages holding bucketed memory have a fast allocation bitmap to manage their blocks internally.

Function Documentation

◆ xnheap_alloc()

void * xnheap_alloc ( struct xnheap *  heap,
size_t  size 
)


Allocate a memory block from a memory heap.

Allocates a contiguous region of memory from an active memory heap. Such allocation is guaranteed to be time-bounded.

Parameters
heapThe descriptor address of the heap to get memory from.
sizeThe size in bytes of the requested block.
Returns
The address of the allocated region upon success, or NULL if no memory is available from the specified heap.
Tags
unrestricted

◆ xnheap_destroy()

void xnheap_destroy ( struct xnheap *  heap)


Destroys a memory heap.

Destroys a memory heap.

Parameters
heapThe heap descriptor.
Tags
secondary-only

◆ xnheap_free()

void xnheap_free ( struct xnheap *  heap,
void *  block 
)


Release a block to a memory heap.

Releases a memory block to a heap.

Parameters
heapThe heap descriptor.
blockThe block to be returned to the heap.
Tags
unrestricted

◆ xnheap_set_name()

void xnheap_set_name ( struct xnheap *  heap,
const char *  name,
  ... 
)


Set the heap's name string.

Set the heap name that will be used in statistic outputs.

Parameters
heapThe address of a heap descriptor.
nameName displayed in statistic outputs. This parameter can be a printk()-like format argument list.
Tags
task-unrestricted