diff options
| author | Taylan Kammer <taylan.kammer@gmail.com> | 2026-08-16 10:01:12 +0200 |
|---|---|---|
| committer | Taylan Kammer <taylan.kammer@gmail.com> | 2026-08-16 10:01:12 +0200 |
| commit | e26e81aa33dc1ecc2f26de26b1d420d288a28493 (patch) | |
| tree | d0c906f3b6d504870a171f57709c6e912a3fc9c4 /src/zisp/gc/IstrPool.zig | |
| parent | 0e073b94c90b78ebe156adb27ec4456e86935d42 (diff) | |
Implemented meta allocator.
Diffstat (limited to 'src/zisp/gc/IstrPool.zig')
| -rw-r--r-- | src/zisp/gc/IstrPool.zig | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/zisp/gc/IstrPool.zig b/src/zisp/gc/IstrPool.zig index bbf6e63..81b4632 100644 --- a/src/zisp/gc/IstrPool.zig +++ b/src/zisp/gc/IstrPool.zig @@ -11,6 +11,7 @@ const std = @import("std"); const Alloc = std.mem.Allocator; +const gc = @import("../gc.zig"); const value = @import("../value.zig"); const Value = value.Value; @@ -130,8 +131,9 @@ fn getOrPutOrNew(self: *Self, sptr: [*]const u8, len: u8, put: ?Value) !Value { fn newIstr(self: *Self, sptr: [*]const u8, len: u8) !Value { // TODO: Alloc manually in slabs, like ListPool FlexiBlock. - const ptr = try self.alloc.alloc(len); - const idx = gc.istrIdxFromPtr(ptr); + const s = try self.alloc.alloc(u8, len); + @memcpy(s, sptr[0..len]); + const idx = gc.istrIdxFromPtr(s.ptr); return .{ .istr = .{ .idx = idx, .len = len } }; } |
