1234567891011121314151617181920212223242526272829 |
- /*
- * sbrk allocator (without disk cache integration)
- */
- #include <stddef.h>
- #include <errno.h>
- #include "sys.h"
- #include "common.h"
- extern char __heap_start[], __heap_end[];
- static char *cur_brk = __heap_start;
- void heap_init(void)
- {
- }
- void * __hot _sbrk(ptrdiff_t increment)
- {
- char *old_brk = cur_brk;
- char *new_brk = old_brk + increment;
- if (unlikely(new_brk > __heap_end)) {
- errno = ENOMEM;
- return (void *)(-1);
- }
- cur_brk = new_brk;
- return old_brk;
- }
|