mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 19:08:50 +00:00
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:
@@ -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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user