From ef805e9373fd946bf1fe667bf18a54dfed6d1045 Mon Sep 17 00:00:00 2001 From: Alejandro Sior Date: Sat, 23 Jul 2022 22:53:47 +0200 Subject: kernel: add basic modules: arch, mem, rt --- mem/allocator.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 mem/allocator.c (limited to 'mem/allocator.c') diff --git a/mem/allocator.c b/mem/allocator.c new file mode 100644 index 0000000..b4d9068 --- /dev/null +++ b/mem/allocator.c @@ -0,0 +1,23 @@ +#include "allocator.h" + +/* Dispatches the alloc call */ +void *mem_alloc(MemAllocator *self, usize n) { + if (self->alloc) + return self->alloc(self, n); + + return nil; +} + +/* Dispatches the realloc call */ +void *mem_realloc(MemAllocator *self, void *ptr, usize n) { + if (self->realloc) + return self->realloc(self, ptr, n); + + return nil; +} + +/* Dispatches the free call */ +void mem_free(MemAllocator *self, void *ptr) { + if (self->free) + self->free(self, ptr); +} \ No newline at end of file -- cgit v1.2.3