diff options
author | 2022-03-14 23:44:07 -0700 | |
---|---|---|
committer | 2022-03-14 23:44:07 -0700 | |
commit | 9a43eb903dbdd619e25faa9bdc9d79b4f32e055d (patch) | |
tree | 88e4edb276f7d59290f71b9276fa78f81c77a769 /src/mimalloc_arena.zig | |
parent | 5a6010deda0bc6f2f31e89c11978d9d62cc70a05 (diff) | |
download | bun-9a43eb903dbdd619e25faa9bdc9d79b4f32e055d.tar.gz bun-9a43eb903dbdd619e25faa9bdc9d79b4f32e055d.tar.zst bun-9a43eb903dbdd619e25faa9bdc9d79b4f32e055d.zip |
cleanup some code
Diffstat (limited to 'src/mimalloc_arena.zig')
-rw-r--r-- | src/mimalloc_arena.zig | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/mimalloc_arena.zig b/src/mimalloc_arena.zig index 21eae175b..2c2f493ce 100644 --- a/src/mimalloc_arena.zig +++ b/src/mimalloc_arena.zig @@ -26,24 +26,22 @@ pub const Arena = struct { pub fn reset(this: *Arena) void { this.deinit(); - this.* = initAssumeCapacity(); + this.* = init() catch unreachable; } pub fn init() !Arena { return Arena{ .heap = mimalloc.mi_heap_new() orelse return error.OutOfMemory }; } - pub fn initAssumeCapacity() Arena { - return Arena{ .heap = mimalloc.mi_heap_new().? }; - } - pub fn gc(this: Arena, force: bool) void { mimalloc.mi_heap_collect(this.heap, force); } + // Copied from rust const MI_MAX_ALIGN_SIZE = 16; inline fn mi_malloc_satisfies_alignment(alignment: usize, size: usize) bool { - return (alignment == @sizeOf(*anyopaque) or (alignment == MI_MAX_ALIGN_SIZE and size > (MI_MAX_ALIGN_SIZE / 2))); + return (alignment == @sizeOf(*anyopaque) or + (alignment == MI_MAX_ALIGN_SIZE and size > (MI_MAX_ALIGN_SIZE / 2))); } fn alignedAlloc(heap: *mimalloc.mi_heap_t, len: usize, alignment: usize) ?[*]u8 { @@ -58,10 +56,6 @@ pub const Arena = struct { return @ptrCast([*]u8, ptr orelse null); } - fn alignedFree(ptr: [*]u8) void { - return mimalloc.mi_free(ptr); - } - fn alloc( arena: *anyopaque, len: usize, |