summaryrefslogtreecommitdiff
path: root/mem/allocator.c
diff options
context:
space:
mode:
Diffstat (limited to 'mem/allocator.c')
-rw-r--r--mem/allocator.c23
1 files changed, 23 insertions, 0 deletions
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