fix: memory leak with injections query

This commit is contained in:
Ryan Mehri 2026-04-11 12:55:38 -04:00 committed by CJ van den Berg
parent 1257180aa7
commit 1384eab9f2
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -484,15 +484,16 @@ pub fn count_error_nodes(self: *const Self) usize {
} }
test "simple build and link test" { test "simple build and link test" {
const io = std.testing.io;
const gpa = std.testing.allocator; const gpa = std.testing.allocator;
const zig_file_type = @import("file_type.zig").get_by_name_static("zig") orelse return error.TestFailed; const zig_file_type = @import("file_type.zig").get_by_name_static("zig") orelse return error.TestFailed;
const query_cache = try QueryCache.create(gpa, .{}); const query_cache = try QueryCache.create(io, gpa, .{});
defer query_cache.deinit(); defer query_cache.deinit();
const syntax = try create(zig_file_type, gpa, query_cache); const syntax = try create(zig_file_type, gpa, query_cache);
defer syntax.destroy(); defer syntax.destroy();
const content = try std.fs.cwd().readFileAlloc(gpa, "src/syntax.zig", std.math.maxInt(usize)); const content = try std.Io.Dir.readFileAlloc(.cwd(), io, "src/syntax.zig", gpa, .unlimited);
defer gpa.free(content); defer gpa.free(content);
try syntax.refresh_full(content); try syntax.refresh_full(content);