Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

fix(windows): keep aligned allocations on mimalloc

News25d08258e567
diff --git a/src/foundation/compat_thread.c b/src/foundation/compat_thread.c
index 94af9f812..b86a7f3fb 100644
--- a/src/foundation/compat_thread.c
+++ b/src/foundation/compat_thread.c
@@ -2,7 +2,7 @@
* compat_thread.c — Portable thread, mutex, and aligned allocation.
*
* POSIX: thin wrappers around pthreads and posix_memalign.
- * Windows: CreateThread, CRITICAL_SECTION, _aligned_malloc.
+ * Windows: CreateThread, CRITICAL_SECTION, aligned allocation.
*/
#include "foundation/mem_events.h"
#include "foundation/constants.h"
@@ -279,12 +279,20 @@ void cbm_mutex_destroy(cbm_mutex_t *m) {
#ifdef _WIN32
int cbm_aligned_alloc(void **ptr, size_t alignment, size_t size) {
+#if defined(CBM_MEM_GLOBAL_OVERRIDE) && CBM_MEM_GLOBAL_OVERRIDE
+ *ptr = mi_malloc_aligned(size, alignment);
+#else
*ptr = _aligned_malloc(size, alignment);
+#endif
return *ptr ? 0 : -1;
}
void cbm_aligned_free(void *ptr) {
+#if defined(CBM_MEM_GLOBAL_OVERRIDE) && CBM_MEM_GLOBAL_OVERRIDE
+ mi_free(ptr);
+#else
_aligned_free(ptr);
+#endif
}
#else /* POSIX */