summaryrefslogtreecommitdiffstats
path: root/lib/liballoc/include/allocator.h
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2024-05-10 02:06:31 +0200
committerLouis Burda <quent.burda@gmail.com>2024-05-10 02:06:31 +0200
commitdc35e35d0ba1bce4cd1ee5f4b1b94c8263b15b43 (patch)
tree0cb58c0a87a7f744a61fd1f648bb9761205bbc1b /lib/liballoc/include/allocator.h
parentc3c03a382eb7dc9a32850da6615316faf4677a23 (diff)
downloadlibidx-c-master.tar.gz
libidx-c-master.zip
Add liballoc as subgitHEADmaster
Diffstat (limited to 'lib/liballoc/include/allocator.h')
-rw-r--r--lib/liballoc/include/allocator.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/liballoc/include/allocator.h b/lib/liballoc/include/allocator.h
new file mode 100644
index 0000000..fc9a13d
--- /dev/null
+++ b/lib/liballoc/include/allocator.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include <stddef.h>
+
+struct allocator {
+ void *(*alloc)(const struct allocator *allocator,
+ size_t size, int *rc);
+ void *(*realloc)(const struct allocator *allocator,
+ void *p, size_t size, int *rc);
+ int (*free)(const struct allocator *allocator, void *p);
+};
+
+struct strict_allocator {
+ const struct allocator *allocator_ul;
+ struct allocator allocator;
+};
+
+void strict_allocator_init(struct strict_allocator *strict_allocator_init,
+ const struct allocator *allocator_ul);
+
+extern const struct allocator stdlib_heap_allocator;
+extern const struct allocator stdlib_strict_heap_allocator;