aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc/alloc.c')
-rw-r--r--src/alloc/alloc.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/alloc/alloc.c b/src/alloc/alloc.c
new file mode 100644
index 0000000..0ff8ff4
--- /dev/null
+++ b/src/alloc/alloc.c
@@ -0,0 +1,26 @@
+#include <alloc.h>
+#include <stdlib.h>
+
+static void* stdcalloc(size_t size){
+ return calloc(1, size);
+}
+
+static void* stdmalloc(size_t size){
+ return malloc(size);
+}
+
+static void* stdrealloc(void* ptr, size_t size){
+ return realloc(ptr, size);
+}
+
+static void stdfree(void* ptr){
+ free(ptr);
+}
+
+
+static struct calt_alloc alloc = {
+ .malloc = stdmalloc, .realloc = stdrealloc, .free = stdfree, .calloc = stdcalloc};
+
+void calt_use_custom_alloc(struct calt_alloc allocator) { alloc = allocator; }
+struct calt_alloc calt_get_alloc(void) { return alloc; }
+