summaryrefslogtreecommitdiff
path: root/src/File.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/File.zig')
-rw-r--r--src/File.zig14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/File.zig b/src/File.zig
index dd6b2d34..84222191 100644
--- a/src/File.zig
+++ b/src/File.zig
@@ -1159,10 +1159,12 @@ pub fn deinit(p: *Pardes, pane: *Pane, file: *State) void {
if (p.panes[id].?.file.?.line_starts.ptr == file.line_starts.ptr) break true;
} else false;
p.gpa.free(file.path);
- if (ntwins == 0) p.gpa.free(file.content);
+ // Raw, as every text is freed (a replica's rollback copy pins them,
+ // src/rollback.zig, and a safe build's free writes over what it frees).
+ if (ntwins == 0) pardes.memory.freeUnfilled(p.gpa, file.content);
if (file.listing) |listing| p.gpa.free(listing.names);
if (file.mini) |*mini| mini.deinit(p.gpa);
- if (file.line_starts.len > 0 and !index_shared) p.gpa.free(file.line_starts);
+ if (file.line_starts.len > 0 and !index_shared) pardes.memory.freeRaw(p.gpa, file.line_starts);
if (file.highlights.len > 0) p.tree_sitter_gpa.free(file.highlights);
p.gpa.free(file.pager_spans);
locations.freeRows(p.gpa, file.location_rows);
@@ -1264,7 +1266,7 @@ pub fn setContentSpan(p: *Pardes, f: *State, new: []u8, span_in: ?Span) void {
};
// The clock the session that recorded read (src/tape.zig).
f.mtime = pardes.tape.value(.mtime, pardes.ctlfs.events.now, .{});
- if (f.line_starts.len > 0) p.gpa.free(f.line_starts);
+ if (f.line_starts.len > 0) pardes.memory.freeRaw(p.gpa, f.line_starts);
f.line_starts = starts;
if (f.highlights.len > 0) p.tree_sitter_gpa.free(f.highlights);
f.highlights = &.{};
@@ -1276,7 +1278,7 @@ pub fn setContentSpan(p: *Pardes, f: *State, new: []u8, span_in: ?Span) void {
const tf = &t.file.?;
// Its own index, built while the shared one was empty, goes; the
// shared one, freed above, is replaced.
- if (tf.line_starts.len > 0 and tf.line_starts.ptr != old_starts) p.gpa.free(tf.line_starts);
+ if (tf.line_starts.len > 0 and tf.line_starts.ptr != old_starts) pardes.memory.freeRaw(p.gpa, tf.line_starts);
tf.content = f.content;
tf.line_starts = f.line_starts;
tf.revision = f.revision;
@@ -1498,8 +1500,8 @@ pub fn relink(p: *Pardes, of: usize, id: usize, dot: ?[2]u32) void {
sf.twin = p.next_twin;
p.next_twin +%= 1;
}
- p.gpa.free(f.content);
- if (f.line_starts.len > 0) p.gpa.free(f.line_starts);
+ pardes.memory.freeUnfilled(p.gpa, f.content);
+ if (f.line_starts.len > 0) pardes.memory.freeRaw(p.gpa, f.line_starts);
f.history.destroy(p.gpa);
f.content = sf.content;
f.line_starts = sf.line_starts;