diff options
author | 2022-02-03 21:03:08 -0800 | |
---|---|---|
committer | 2022-02-03 21:03:08 -0800 | |
commit | 3c9e30ffcd47db408194c5e3b50bc890366f3ec0 (patch) | |
tree | ee2c080015b320e778858d32888b2c37c09eec00 /src/mimalloc_arena.zig | |
parent | b22a3f59730385501cff0f9ab76888373415a2f6 (diff) | |
download | bun-3c9e30ffcd47db408194c5e3b50bc890366f3ec0.tar.gz bun-3c9e30ffcd47db408194c5e3b50bc890366f3ec0.tar.zst bun-3c9e30ffcd47db408194c5e3b50bc890366f3ec0.zip |
Update mimalloc_arena.zig
Diffstat (limited to 'src/mimalloc_arena.zig')
-rw-r--r-- | src/mimalloc_arena.zig | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mimalloc_arena.zig b/src/mimalloc_arena.zig index db7a6c368..e2df152fb 100644 --- a/src/mimalloc_arena.zig +++ b/src/mimalloc_arena.zig @@ -23,10 +23,19 @@ pub const Arena = struct { mimalloc.mi_heap_destroy(this.heap); } + pub fn reset(this: *Arena) void { + this.deinit(); + this.* = initAssumeCapacity(); + } + 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); } |