From 398270fb7e121cbaab9e264a39bc83b5d32c40c7 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 23:07:25 -0300 Subject: locations: one appendRow copies a row's path and colours onto a list being built, for appendMetadata, hunks' Out.row and Query's writeRow, which each copied, appended and freed on failure by hand Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/hunks.zig | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/hunks.zig') diff --git a/src/hunks.zig b/src/hunks.zig index 8cd5c43a..ae7b5966 100644 --- a/src/hunks.zig +++ b/src/hunks.zig @@ -125,21 +125,16 @@ const Out = struct { /// One row: its text, a newline, and its metadata. fn row(out: *Out, text: []const u8, path: []const u8, meta: Meta) !void { - const gpa = out.p.gpa; try out.text.writer.writeAll(text); try out.text.writer.writeByte('\n'); - const owned_path = try gpa.dupe(u8, path); - errdefer gpa.free(owned_path); - const colors = try gpa.dupe(u8, meta.colors); - errdefer gpa.free(colors); - try out.rows.append(gpa, .{ + try locations.appendRow(out.p.gpa, &out.rows, .{ .kind = meta.kind, .declaration = meta.declaration, - .path = owned_path, + .path = @constCast(path), .at = meta.at, .location_end = meta.location_end, .code_start = meta.code_start, - .colors = colors, + .colors = @constCast(meta.colors), }); } }; -- cgit v1.3