/* * sbrk allocator */ #include #include #include "sys.h" #include "fw.h" void *_sbrk(size_t increment) { static size_t cur_brk = (size_t)_end; size_t old_brk = cur_brk; size_t new_brk = old_brk + increment; if (unlikely(new_brk > SRAM_SIZE - STACK_SIZE)) { errno = ENOMEM; return (void *)(-1); } cur_brk = new_brk; return (void *)old_brk; }