Fix z_allocator implementation when use_mimalloc is false; make Bun compile with use_mimalloc false (#21771)

We can't use `std.heap.c_allocator` as `z_allocator`; it doesn't
zero-initialize the memory. This PR adds a fallback implementation.

This PR also makes Bun compile successfully with `use_mimalloc` set to
false. More work is likely necessary to make it function correctly in
this case, but it should at least compile.

(For internal tracking: fixes STAB-978, STAB-979)
This commit is contained in:
taylor.fish
2025-08-11 20:20:58 -07:00
committed by GitHub
parent 41b1efe12c
commit 0c83ff3f7e
7 changed files with 71 additions and 16 deletions

View File

@@ -142,6 +142,11 @@ const z_allocator_vtable = Allocator.VTable{
.free = &ZAllocator.free_with_z_allocator,
};
/// mimalloc can free allocations without being given their size.
pub fn freeWithoutSize(ptr: ?*anyopaque) void {
mimalloc.mi_free(ptr);
}
const Environment = @import("../env.zig");
const std = @import("std");