From 617ddc62aa4d3153850362526069b85bfaf5e59e Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 31 Jan 2026 15:31:15 +0900 Subject: use reference counting to manage JSON value lifetime --- src/root.zig | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/root.zig') diff --git a/src/root.zig b/src/root.zig index e61ed1f..e2152d3 100644 --- a/src/root.zig +++ b/src/root.zig @@ -12,6 +12,7 @@ pub fn run(allocator: std.mem.Allocator, input: []const u8, query: []const u8) ! try runtime.compileFromSlice(query); try runtime.start(json); const result = try runtime.next() orelse return error.NoResult; + defer result.deinit(allocator); const output = try jv.stringify(allocator, result); return output; } @@ -34,6 +35,7 @@ fn testRunMultiple(expected: []const []const u8, input: []const u8, query: []con for (expected) |ex| { const result_value = try runtime.next() orelse return error.NoResult; + defer result_value.deinit(allocator); const result = try jv.stringify(allocator, result_value); defer allocator.free(result); try std.testing.expectEqualStrings(ex, result); -- cgit v1.3-1-g0d28