1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <stddef.h> extern char _end[]; static char *curbrk = _end; extern char _heapend; /* End of heap */ void * sbrk (ptrdiff_t incr) { char *oldbrk = curbrk; if (curbrk + incr > &_heapend) return (void *) -1; curbrk += incr; return oldbrk; }