aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-05-09 15:17:35 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-05-09 15:17:35 +0200
commit7059e4e133b62f5ad3339d51966f226089532710 (patch)
tree94f3124e189d4329f7ee52ff69fd6619754bcafe /include
parent6cd517eee582d797d766f3ed8dfbfb8c107eed7c (diff)
Try to do better error handling with custom allocators
Diffstat (limited to 'include')
-rw-r--r--include/alloc.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/alloc.h b/include/alloc.h
index 966361e..b9e03e2 100644
--- a/include/alloc.h
+++ b/include/alloc.h
@@ -1,6 +1,7 @@
#ifndef MLIB_ALLOC_H
#define MLIB_ALLOC_H
+#include <setjmp.h>
#include <stddef.h>
#include "_attrs.h"
@@ -44,6 +45,15 @@ void arena_free(arena *);
#define arena_resz(a, T, p, n) \
((T *)arena_realloc((a), (p), (n), sizeof(T), alignof(T)))
+/* Memory allocator callbacks for memory-allocating functions */
+struct arena_ctx {
+ arena *a;
+ jmp_buf *jmp;
+};
+struct heap_ctx {
+ jmp_buf *jmp;
+};
+
[[nodiscard]] void *alloc_arena(void *, void *, size_t, size_t, size_t);
[[nodiscard]] void *alloc_heap(void *, void *, size_t, size_t, size_t);