You copied the Doc URL to your clipboard.


If defined, the __user_heap_extent() function returns the bounds of the memory available to the Heap2 allocator.

See rt_misc.h.


For AArch32 targets:

extern __attribute__((value_in_regs)) struct __heap_extent __user_heap_extent(unsigned ignore1, size_t ignore2);

For AArch64 targets:

extern __attribute__((value_in_regs)) struct __heap_extent __user_heap_extent(unsigned long ignore1, size_t ignore2);


The parameters ignore1 and ignore2 are the default values for the base address and size of the heap. They are for information only and can be ignored.

You only need to implement this function if you are using the Heap2 allocator, which is also part of the C library. This function has no default implementation. The Heap2 allocator calls it during heap initialization to determine the maximum address range that the heap can occupy. The function returns the base address of the heap and the total number of bytes available to the heap, rounded up to the next power of two.

For example, if you want to specify that all your heap allocations will come from address 0x80000000 and above, and that the heap has a total maximum size of 3MiB, __user_heap_extent() should return base=0x80000000 and range=0x400000, which is 3MiB rounded up to the next power of two.