summaryrefslogtreecommitdiff
path: root/lua_benchmark/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'lua_benchmark/main.c')
-rw-r--r--lua_benchmark/main.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/lua_benchmark/main.c b/lua_benchmark/main.c
index ddcf2fe..9ad2cc1 100644
--- a/lua_benchmark/main.c
+++ b/lua_benchmark/main.c
@@ -117,6 +117,30 @@ void *calloc(size_t cnt, size_t size) {
return (void*)data;
}
+#elif defined(ALLOC_BASELINE_BUDDY)
+
+#define BUDDY_ALLOC_IMPLEMENTATION
+#include "baselines/buddy_alloc.h"
+
+const size_t POOL_SIZE = 1024 * 1024 * 1024;
+struct buddy *BUDDY;
+void *POOL;
+
+static void init_allocator() {
+ /* You need space for arena and builtin metadata */
+ POOL = malloc(POOL_SIZE);
+ BUDDY = buddy_embed(POOL, POOL_SIZE);
+}
+
+static void *allocator_fn(void *ud, void *ptr, size_t osize, size_t nsize) {
+ // https://www.lua.org/manual/5.4/manual.html#4.6
+ if (nsize == 0) {
+ buddy_free(BUDDY, ptr);
+ return NULL;
+ }
+ return buddy_realloc(BUDDY, ptr, nsize, 0);
+}
+
#elif defined(ALLOC_SYSTEM)
static void init_allocator() { }
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback