summaryrefslogtreecommitdiff
path: root/src/zisp/value
diff options
context:
space:
mode:
Diffstat (limited to 'src/zisp/value')
-rw-r--r--src/zisp/value/istr.zig10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/zisp/value/istr.zig b/src/zisp/value/istr.zig
index 9156606..90eccb6 100644
--- a/src/zisp/value/istr.zig
+++ b/src/zisp/value/istr.zig
@@ -58,7 +58,15 @@ fn assertValidIstr(s: []const u8) void {
}
}
-fn pack(istr: IstrPtr) Value {
+pub fn new(alloc: Alloc, s: []const u8) !IstrPtr {
+ const algn = std.mem.Alignment.of(IstrPtr);
+ const size = @sizeOf(IstrHead) + s.len;
+ const istr: IstrPtr = @ptrCast(try alloc.alignedAlloc(u8, algn, size));
+ istr.putStr(s);
+ return istr;
+}
+
+pub fn pack(istr: IstrPtr) Value {
return value.ptr.pack(@ptrCast(istr), .istr);
}