_sbrk in TI

This commit is contained in:
Sergio R. Caprile 2023-02-17 11:11:31 -03:00
parent b9424e4c21
commit b29d6b4478

View File

@ -12,8 +12,11 @@ void *_sbrk(int incr) {
extern char _end;
static unsigned char *heap = NULL;
unsigned char *prev_heap;
unsigned char x = 0, *heap_end = (unsigned char *)((size_t) &x - 512);
(void) x;
if (heap == NULL) heap = (unsigned char *) &_end;
prev_heap = heap;
if (heap + incr > heap_end) return (void *) -1;
heap += incr;
return prev_heap;
}