Last active
December 17, 2022 16:31
-
-
Save michahoiting/a03a89a07f7ad3d13fd889f6dc902361 to your computer and use it in GitHub Desktop.
A very naive implementation of the newlib _sbrk dependency function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! A very naive implementation of the newlib _sbrk dependency function | |
caddr_t _sbrk(int incr); | |
caddr_t _sbrk(int incr) { | |
static uint32_t s_index = 0; | |
static uint8_t s_newlib_heap[2048] __attribute__((aligned(8))); | |
if ((s_index + (uint32_t)incr) <= sizeof(s_newlib_heap)) { | |
EXAMPLE_LOG("Out of Memory!"); | |
return 0; | |
} | |
caddr_t result = (caddr_t)&s_newlib_heap[s_index]; | |
s_index += (uint32_t)incr; | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment