summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabrice <fabrice@schaub-dev.xyz>2026-03-01 22:39:50 +0100
committerFabrice <fabrice@schaub-dev.xyz>2026-03-01 22:39:50 +0100
commita07e37de3f2b56b577da32b33d3dec45e0cd43b6 (patch)
treebf7f397e04ca87fbd6f3b8f41b86e493ec1a6f26
parent6224b633ffd1692fdb4e9422fe5ee7d9db37d565 (diff)
use mi directly
-rw-r--r--makefile3
-rw-r--r--src/memory.cc6
2 files changed, 6 insertions, 3 deletions
diff --git a/makefile b/makefile
index aee39a2..dacc687 100644
--- a/makefile
+++ b/makefile
@@ -26,6 +26,7 @@ MI_FLAGS := -G"Unix Makefiles" -DCMAKE_C_COMPILER=$(CC) \
TOP_DIR := .
SRC_DIR := $(TOP_DIR)/src
MI_DIR := $(TOP_DIR)/mimalloc
+MI_INCLUDE_DIR := $(MI_DIR)/include
MI_O := $(MI_DIR)/mimalloc.o
@@ -42,6 +43,8 @@ $(MI_O): $(MI_DIR)
$(CMAKE) $(MI_FLAGS) -S $(MI_DIR) -B $(MI_DIR)
$(MAKE) -C $(MI_DIR)
+$(VOIDC_O): CCXX_FLAGS += -I$(MI_INCLUDE_DIR)
+
$(VOIDC): $(VOIDC_O) $(MI_O)
$(PRINTF) " CXXLD %s\n" $<
$(CXX) $^ -o $@ $(LD_FLAGS)
diff --git a/src/memory.cc b/src/memory.cc
index c27c6f3..518b761 100644
--- a/src/memory.cc
+++ b/src/memory.cc
@@ -2,8 +2,8 @@
#define MEMORY_CC
#include "common.cc"
-#include <cstdlib>
#include <cstring>
+#include <mimalloc.h>
typedef u8* (*Allocator_Allocate)(u8* self, usize length, usize align);
typedef void (*Allocator_Deallocate)(u8* self, u8* ptr);
@@ -24,12 +24,12 @@ void deallocate(Allocator* allocator, u8* ptr) {
static inline u8* heap_allocate(u8* self, usize size, usize align) {
(void)self;
- return (u8*)aligned_alloc(align, size);
+ return (u8*)mi_aligned_alloc(align, size);
}
static inline void heap_deallocate(u8* self, u8* ptr) {
(void)self;
- free(ptr);
+ mi_free(ptr);
}
Allocator* heap_allocator() {