1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 23:24:09 +00:00
This commit is contained in:
Rene Schallner 2023-09-12 14:10:24 +02:00
parent 0551bcebfb
commit 83220302d7

View file

@ -26,7 +26,7 @@ pub const FreeOrNot = struct {
pub fn fio2strAllocOrNot(o: fio.FIOBJ, a: std.mem.Allocator, always_alloc: bool) !FreeOrNot {
if (o == 0) return .{ .str = "null", .freeme = false };
if (o == fio.FIOBJ_INVALID) return .{ .str = "null", .freeme = false };
if (o == fio.FIOBJ_INVALID) return .{ .str = "invalid", .freeme = false };
return switch (fio.fiobj_type(o)) {
fio.FIOBJ_T_TRUE => .{ .str = "true", .freeme = false },
fio.FIOBJ_T_FALSE => .{ .str = "false", .freeme = false },
@ -35,7 +35,7 @@ pub fn fio2strAllocOrNot(o: fio.FIOBJ, a: std.mem.Allocator, always_alloc: bool)
fio.FIOBJ_T_FLOAT => .{ .str = try a.dupe(u8, fio2str(o) orelse "null"), .freeme = true, .allocator = a },
// the string comes out of the request, so it is safe to not make a copy
fio.FIOBJ_T_STRING => .{ .str = if (always_alloc) try a.dupe(u8, fio2str(o) orelse "") else fio2str(o) orelse "", .freeme = if (always_alloc) true else false, .allocator = a },
else => .{ .str = "null", .freeme = false },
else => .{ .str = "unknown_type", .freeme = false },
};
}
pub fn str2fio(s: []const u8) fio.fio_str_info_s {