From 7059e4e133b62f5ad3339d51966f226089532710 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Thu, 9 May 2024 15:17:35 +0200 Subject: Try to do better error handling with custom allocators --- include/alloc.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') 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 #include #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); -- cgit v1.2.3