Datasheet

The C and C++ Libraries
4-58 Copyright © 1999-2001 ARM Limited. All rights reserved. ARM DUI 0067D
This implementation has low overheads, but the cost of
malloc()
or
free()
grows
linearly with the number of free blocks. The smallest block that can be allocated is four
bytes and there is an additional overhead of four bytes. If you expect more than 100
unallocated blocks it is recommended that you use Heap2.
Heap2: Alternative heap implementation
Heap2 provides a compact implementation with the cost of
malloc()
or
free()
growing
logarithmically with the number of free blocks. The allocation policy is first-fit by
address. The smallest block that can be allocated is 12 bytes and there is an additional
overhead of four bytes.
Heap2 is recommended when you require near constant-time performance in the
presence of hundreds of free blocks. To select the alternative standard implementation,
use either:
IMPORT __use_realtime_heap
from assembly language
#pragma import(__use_realtime_heap)
from C.
You can also define your own heap implementation. See Creating your own
storage-management system on page 4-60 for more information.
Using Heap2
The Heap2 real-time heap implementation must know how much address space the heap
will span. The smaller the address range, the more efficient the algorithm is.
By default, the heap extent is taken to be 16MB starting at the beginning of the heap
(defined as the start of the first chunk of memory given to the heap manager by
__rt_initial_stackheap()
or
__rt_heap_extend()
).
The heap bounds are given by:
struct __heap_extent {
unsigned base, range;};
__value_in_regs struct __heap_extent __user_heap_extent(
unsigned defaultbase, unsigned defaultsize);
The function prototype for
__user_heap_extent()
is in
rt_misc.h
.
The Heap1 algorithm does not require the bounds on the heap extent, therefore it never
calls this function.
You must redefine
__user_heap_extent()
if:
you require a heap to span more than 16MB of address space