Skip to content

Commit a47bf45

Browse files
make _sbrk() WEAK so the user can override it, e.g. to make malloc() always use external memory
1 parent f907012 commit a47bf45

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

platform/mbed_retarget.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,8 @@ extern "C" caddr_t _sbrk(int incr) {
770770
#else
771771
// Linker defined symbol used by _sbrk to indicate where heap should start.
772772
extern "C" uint32_t __end__;
773-
extern "C" caddr_t _sbrk(int incr) {
773+
// Weak attribute allows user to override, e.g. to use external RAM for dynamic memory.
774+
extern "C" WEAK caddr_t _sbrk(int incr) {
774775
static unsigned char* heap = (unsigned char*)&__end__;
775776
unsigned char* prev_heap = heap;
776777
unsigned char* new_heap = heap + incr;

0 commit comments

Comments
 (0)