mirror of
https://github.com/Polprzewodnikowy/SummerCart64.git
synced 2024-12-27 21:41:55 +01:00
23 lines
495 B
C
23 lines
495 B
C
|
#include <errno.h>
|
||
|
#include <sys/types.h>
|
||
|
|
||
|
|
||
|
extern char _sheap __attribute__((section(".data")));
|
||
|
extern char _eheap __attribute__((section(".data")));
|
||
|
|
||
|
|
||
|
caddr_t _sbrk_r (struct _reent *prt, ptrdiff_t incr) {
|
||
|
static char *curr_heap_end = &_sheap;
|
||
|
char *prev_heap_end;
|
||
|
|
||
|
prev_heap_end = curr_heap_end;
|
||
|
curr_heap_end += incr;
|
||
|
|
||
|
if (curr_heap_end > &_eheap) {
|
||
|
errno = ENOMEM;
|
||
|
return (caddr_t) -1;
|
||
|
}
|
||
|
|
||
|
return (caddr_t) prev_heap_end;
|
||
|
}
|