make _sbrk() WEAK so the user can override it, e.g. to make malloc() always use external memory

pull/5994/head
Brendan McDonnell 2017-12-06 11:19:20 -05:00
parent f907012e55
commit a47bf4595f
1 changed files with 2 additions and 1 deletions

View File

@ -770,7 +770,8 @@ extern "C" caddr_t _sbrk(int incr) {
#else
// Linker defined symbol used by _sbrk to indicate where heap should start.
extern "C" uint32_t __end__;
extern "C" caddr_t _sbrk(int incr) {
// Weak attribute allows user to override, e.g. to use external RAM for dynamic memory.
extern "C" WEAK caddr_t _sbrk(int incr) {
static unsigned char* heap = (unsigned char*)&__end__;
unsigned char* prev_heap = heap;
unsigned char* new_heap = heap + incr;