diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-30 19:37:42 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-30 20:01:36 -0300 |
| commit | 9bd34ae2afdb05713f312e7e58dc3d516ea84ebe (patch) | |
| tree | 474095187ebf00950666de755d0ec759aaa7dc40 /src/locations.zig | |
| parent | 257eec0ae161b28f69b6c6fa8aae03ecc1bf85f0 (diff) | |
| download | pardes-9bd34ae2afdb05713f312e7e58dc3d516ea84ebe.tar.gz pardes-9bd34ae2afdb05713f312e7e58dc3d516ea84ebe.zip | |
Query: a +Search's rows recoloured are made again (locations.cloneRows, Query.save's copy), never written in place: the rows are a blob (File.State location_rows), whose word a digest keeps by address and a replica's rollback copy pins, so a release session kept the word of their colours before a paint landed (recolor's @memcpy); an edit moved them into dropped_marks with the stale word, a replica that hashed them at another time diverged there (fixer 1's soak: `pane 5.file.dropped_marks`), and a client loading the session's dump hashed the colours it carried and loaded "as another session"; dropped_marks stays in the digest, as an undo back to its text reads it; Stream's test, which a Debug build fails before (`the 82-byte blob ... is not what its kept word was: written in place`)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/locations.zig')
| -rw-r--r-- | src/locations.zig | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/locations.zig b/src/locations.zig index 40f22f85..d0904607 100644 --- a/src/locations.zig +++ b/src/locations.zig @@ -36,6 +36,30 @@ pub fn freeRows(gpa: std.mem.Allocator, rows: []Row) void { freeRaw(gpa, rows); } +/// A copy of `rows` and all they own, gpa's: rows are a blob (File.State +/// `location_rows`), made again rather than written. +pub fn cloneRows(gpa: std.mem.Allocator, rows: []const Row) ![]Row { + const out = try gpa.alloc(Row, rows.len); + var made: usize = 0; + errdefer { + for (out[0..made]) |r| { + gpa.free(r.path); + gpa.free(r.colors); + } + gpa.free(out); + } + for (rows, out) |r, *o| { + o.* = r; + o.path = try gpa.dupe(u8, r.path); + o.colors = gpa.dupe(u8, r.colors) catch |err| { + gpa.free(o.path); + return err; + }; + made += 1; + } + return out; +} + /// A list of rows being built, given up: each row's own bytes, then the list. pub fn freeRowList(gpa: std.mem.Allocator, rows: *std.ArrayList(Row)) void { for (rows.items) |row| { |
