diff options
Diffstat (limited to 'src/memory.zig')
| -rw-r--r-- | src/memory.zig | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/memory.zig b/src/memory.zig index 1d082964..7adcf914 100644 --- a/src/memory.zig +++ b/src/memory.zig @@ -1,5 +1,6 @@ const std = @import("std"); const builtin = @import("builtin"); +const walk = @import("walk.zig"); const config = @import("pardes_config"); const board = config.platform == .esp32p4; @@ -418,7 +419,10 @@ pub fn dupeUnfilled(allocator: Allocator, bytes: []const u8) Allocator.Error![]u /// Frees without the safe-build overwrite `free` does, for text-sized buffers /// freed on every edit. pub fn freeUnfilled(allocator: Allocator, bytes: []const u8) void { - if (bytes.len > 0) allocator.rawFree(@constCast(bytes), .of(u8), @returnAddress()); + if (bytes.len == 0) return; + // A blob's digest word goes with it (walk.zig). + walk.forget(@intFromPtr(bytes.ptr)); + allocator.rawFree(@constCast(bytes), .of(u8), @returnAddress()); } /// `freeUnfilled` for a slice of any element: a text's line index, made @@ -427,7 +431,9 @@ pub fn freeUnfilled(allocator: Allocator, bytes: []const u8) void { pub fn freeRaw(allocator: Allocator, items: anytype) void { const E = @typeInfo(@TypeOf(items)).pointer.child; const bytes = std.mem.sliceAsBytes(items); - if (bytes.len > 0) allocator.rawFree(@constCast(bytes), .of(E), @returnAddress()); + if (bytes.len == 0) return; + walk.forget(@intFromPtr(bytes.ptr)); + allocator.rawFree(@constCast(bytes), .of(E), @returnAddress()); } /// Gives free memory back to the system, the arenas' and libc's, inside its |
