Synergy Software Package User's Manual

Functions

caddr_t _sbrk (int incr)
 SSP implementation of the standard library _sbrk() function. More...
 

Detailed Description

Function Documentation

◆ _sbrk()

caddr_t _sbrk ( int  incr)

SSP implementation of the standard library _sbrk() function.

Parameters
[in]incrThe number of bytes being asked for by malloc().
Note
This function overrides the _sbrk version that exists in the newlib library that is linked with. That version improperly relies on the SP as part of it's allocation strategy. This is bad in general and worse in an RTOS environment. This version insures that we allocate the byte pool requested by malloc() only from our allocated HEAP area. Also note that newlib is pre-built and forces the pagesize used by malloc() to be 4096. That requires that we have a HEAP of at least 4096 if we are to support malloc().
Return values
Addressof allocated area if successful, -1 otherwise.

< Defined by the linker.

< Defined by the linker.

Need to align heap to word boundary, else will get

hard faults on Cortex-M0. So we assume that heap starts on

word boundary, hence make sure we always add a multiple of

4 to it.

< align value to 4

Heap has overflowed