1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <kernel/mem.h> extern void *_kernel_end; static void *highest; void mem_init() { highest = &_kernel_end; } // should always succeed, there are no error checks anywhere void *malloc(size_t size) { void *block = highest; highest += size; return block; } void free(void *ptr) { // not implemented }