summaryrefslogtreecommitdiff
path: root/mem/allocator.c
blob: b4d9068ebcaa7ab9286f40897820e54b85e1c47f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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);
}