aboutsummaryrefslogtreecommitdiff
path: root/src/zee_alloc.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-05-07 23:34:16 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-05-07 23:34:16 -0700
commite70ac2ce825ecf5f2d6aa16152801612bf23be8d (patch)
tree3909a1f32e12051389180034ee027c19656efabb /src/zee_alloc.zig
parent12615602144288b3123f352e5d586714bc01b4dc (diff)
downloadbun-e70ac2ce825ecf5f2d6aa16152801612bf23be8d.tar.gz
bun-e70ac2ce825ecf5f2d6aa16152801612bf23be8d.tar.zst
bun-e70ac2ce825ecf5f2d6aa16152801612bf23be8d.zip
wip
Former-commit-id: 79223472f7bb22c4de1f872a542f185aa7189aaa
Diffstat (limited to 'src/zee_alloc.zig')
-rw-r--r--src/zee_alloc.zig10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/zee_alloc.zig b/src/zee_alloc.zig
index ab98fe854..b1f56e726 100644
--- a/src/zee_alloc.zig
+++ b/src/zee_alloc.zig
@@ -28,7 +28,7 @@ pub fn ZeeAlloc(comptime conf: Config) type {
/// The definitiveā„¢ way of using `ZeeAlloc`
pub const wasm_allocator = &_wasm.allocator;
- var _wasm = init(&wasm_page_allocator);
+ pub var _wasm = init(&wasm_page_allocator);
jumbo: ?*Slab = null,
slabs: [total_slabs]?*Slab = [_]?*Slab{null} ** total_slabs,
@@ -157,7 +157,7 @@ pub fn ZeeAlloc(comptime conf: Config) type {
return .{ .backing_allocator = allocator };
}
- pub fn deinit(self: *Self) void {
+ pub fn freeAll(self: *Self) void {
{
var iter = self.jumbo;
while (iter) |node| {
@@ -174,6 +174,10 @@ pub fn ZeeAlloc(comptime conf: Config) type {
self.backing_allocator.destroy(node);
}
}
+ }
+
+ pub fn deinit(self: *Self) void {
+ self.freeAll();
self.* = undefined;
}
@@ -285,7 +289,7 @@ pub fn ZeeAlloc(comptime conf: Config) type {
};
}
-var wasm_page_allocator = init: {
+pub var wasm_page_allocator = init: {
if (!std.builtin.target.isWasm()) {
@compileError("wasm allocator is only available for wasm32 arch");
}