Red-Black Tree Heap API.
More...
|
file | rbheap.c |
| Red-Black Tree Heap implementation.
|
|
Red-Black Tree Heap API.
The red-black tree heap provides a memory allocator suitable to implement the malloc() and free() interface. It uses a first-fit allocation strategy. In the red-black tree heap the administration data structures are not contained in the managed memory area. Thus writing beyond the boundaries of a chunk does not damage the data to maintain the heap. This can be used for example in a task stack allocator which protects the task stacks from access by other tasks. The allocated and free memory parts of the managed area are called chunks. Each chunk needs a descriptor which is stored outside of the managed area.
◆ rtems_rbheap_extend_descriptors
◆ rtems_rbheap_allocate()
Allocates a chunk of memory of at least size bytes from the red-black tree heap control.
The chunk begin is aligned by the value specified in rtems_rbheap_initialize().
- Parameters
-
[in,out] | control | The red-black tree heap. |
[in] | size | The requested chunk size in bytes. |
- Return values
-
NULL | Not enough free space in the heap. |
otherwise | Pointer to allocated chunk of memory. |
◆ rtems_rbheap_free()
Frees a chunk of memory ptr allocated from the red-black tree heap control.
- Parameters
-
[in,out] | control | The red-black tree heap. |
[in] | ptr | The pointer to the chunk of memory. |
- Return values
-
RTEMS_SUCCESSFUL | Successful operation. |
RTEMS_INVALID_ID | The chunk of memory is not a valid chunk in the red-black tree heap. |
RTEMS_INCORRECT_STATE | The chunk of memory is not in the right state. |
◆ rtems_rbheap_initialize()
Initializes the red-black tree heap control.
- Parameters
-
[in,out] | control | The red-black tree heap. |
[in] | area_begin | The managed memory area begin. |
[in] | area_size | The managed memory area size. |
[in] | alignment | The minimum chunk alignment. |
[in] | extend_descriptors | The handler to extend the available chunk descriptors. |
[in] | handler_arg | The handler argument. |
- Return values
-
RTEMS_SUCCESSFUL | Successful operation. |
RTEMS_INVALID_ADDRESS | The memory area is invalid. |
RTEMS_NO_MEMORY | Not enough chunk descriptors. |