aboutsummaryrefslogtreecommitdiff
path: root/include/_allocator.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/_allocator.h')
-rw-r--r--include/_allocator.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/_allocator.h b/include/_allocator.h
new file mode 100644
index 0000000..3bd78b2
--- /dev/null
+++ b/include/_allocator.h
@@ -0,0 +1,22 @@
+#ifndef MLIB__ALLOCATOR_H
+#define MLIB__ALLOCATOR_H
+
+#include <setjmp.h>
+#include <stddef.h>
+
+typedef enum {
+ ALLOC_NEW,
+ ALLOC_RESIZE,
+ ALLOC_FREE,
+ ALLOC_FREEALL,
+} alloc_mode_t;
+
+typedef struct allocator {
+ void *(*alloc)(struct allocator mem, alloc_mode_t mode, void *ptr,
+ ptrdiff_t oldnmemb, ptrdiff_t newnmemb, ptrdiff_t elemsz,
+ ptrdiff_t align);
+ jmp_buf *err;
+ void *ctx;
+} allocator_t;
+
+#endif /* !MLIB__ALLOCATOR_H */