diff options
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 } }; } |
