Skip to content

Instantly share code, notes, and snippets.

@klange
Created March 25, 2011 05:56
Show Gist options
  • Save klange/886417 to your computer and use it in GitHub Desktop.
Save klange/886417 to your computer and use it in GitHub Desktop.
toaru's internal sbrk()
void *
sbrk(
uintptr_t increment
) {
ASSERT(increment % 0x1000 == 0);
ASSERT(heap_end % 0x1000 == 0);
uintptr_t address = heap_end;
heap_end += increment;
uintptr_t i;
for (i = address; i < heap_end; i += 0x1000) {
get_page(i, 1, kernel_directory);
alloc_frame(get_page(i, 1, kernel_directory), 0, 1);
}
return (void *)address;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment