extern uint32_t __end__; /* Defined by the linker */
void* sbrk(size_t incr) {
- uint32_t *prev_heap_end;
+ uint32_t *prev_heap_end;
- if (heap_end == NULL) {
- heap_end = &__end__;
- }
-
- // FIXME - Make sure heap isn't leaking into stack here. That would be bad.
-
- prev_heap_end = heap_end;
+ if (heap_end == NULL) {
+ heap_end = &__end__;
+ }
- heap_end += incr;
+ // FIXME - Make sure heap isn't leaking into stack here. That would be bad.
- memset(prev_heap_end, 0, (uint32_t)heap_end - (uint32_t)prev_heap_end); // Clear heap.
+ prev_heap_end = heap_end;
- return (void*) prev_heap_end;
+ heap_end += incr;
+ return (void*) prev_heap_end;
}
// This is an incredibly crappy and inefficient implementation of malloc/free nicked from stackoverflow.