|Non-Confidential||PDF version||ARM DUI0475M|
|Home > The ARM C and C++ Libraries > Tailoring the C library to a new execution environment > Emergency buffer memory for exceptions|
You can choose whether or not to allocate emergency memory that is to be used for throwing a std::bad_alloc exception when the heap is exhausted.
To allocate emergency memory, you must include the symbol __ARM_exceptions_buffer_required in
the link. A call is then made to
part of the exceptions system initialization. The symbol is not
included by default.
The following routines manage the exceptions emergency buffer:
extern "C" void *__ARM_exceptions_buffer_init()
Called once during runtime to allocate the emergency
buffer memory. It returns a pointer to the emergency buffer memory,
NULL if no memory is allocated.
extern "C" void *__ARM_exceptions_buffer_allocate(void *
Called when an exception is about to be thrown,
but there is not enough heap memory available to allocate the exceptions
is the value previously returned
that routine was not called.
a pointer to
bytes of memory
that is aligned on an eight-byte boundary, or
the allocation is not possible.
extern "C" void *__ARM_exceptions_buffer_free(void *
buffer, void *
Called to free memory possibly allocated by
the value previously returned by
NULL if that routine was not called. The routine
determines whether the passed address has been allocated from the emergency
memory buffer, and if so, frees it appropriately, then returns a non-
If the memory at
was not allocated
routine must return
Default definitions of these routines are present in the image,
but you can supply your own versions to override the defaults supplied
by the library. The default routines reserve enough space for a
single std::bad_alloc exceptions object.
If you do not require an emergency buffer, it is safe to redefine
all these routines to return only