Datasheet
The C and C++ Libraries
ARM DUI 0067D Copyright © 1999-2001 ARM Limited. All rights reserved. 4-57
4.8 Tailoring storage management
This section describes the functions from
rt_heap.h
that you can define if you are
tailoring memory management. There are also two helper functions that you can call
from your heap implementation.
See the
rt_heap.h
and
rt_memory.s
include files for more information on
memory-related functions.
Note
Users who are developing embedded systems with limited RAM might require a system
that does not use the heap or any heap-using functions. Other users might require their
own heap functions. There are two library functions that can be included to cause a
warning message if the heap is used:
__use_no_heap()
Guards against use of
malloc()
,
realloc()
,
free()
, and any function that
uses those (such as
calloc()
and
stdio
).
__use_no_heap_region()
Has the same properties as
__use_no_heap()
, but in addition, guards
against other things that use the heap memory region. For example, if you
declare
main()
as a function taking arguments, the heap region is used for
collecting
argc
and
argv
.
4.8.1 Support for malloc
malloc()
,
realloc()
,
calloc()
, and
free()
are built on a heap abstract data type. You can
either:
• Choose between Heap1 or Heap2, the two provided heap implementations.
• Write your own heap implementation of the abstract data type for heap. See
Creating your own storage-management system on page 4-60.
The default implementations of
malloc()
,
realloc()
, and
calloc()
maintain an 8-byte
aligned heap.
Heap1: Standard heap implementation
Heap1, the default implementation, implements the smallest and simplest heap
manager. The heap is managed as a singly-linked list of free blocks held in increasing
address order. The allocation policy is first-fit by address.