diff options
Diffstat (limited to 'src/memory.zig')
| -rw-r--r-- | src/memory.zig | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/memory.zig b/src/memory.zig index 47bd755d..1d082964 100644 --- a/src/memory.zig +++ b/src/memory.zig @@ -421,6 +421,15 @@ pub fn freeUnfilled(allocator: Allocator, bytes: []const u8) void { if (bytes.len > 0) allocator.rawFree(@constCast(bytes), .of(u8), @returnAddress()); } +/// `freeUnfilled` for a slice of any element: a text's line index, made +/// anew at every edit too (and pinned by a replica's rollback copy, +/// src/rollback.zig, which a safe build's overwrite would spoil). +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()); +} + /// Gives free memory back to the system, the arenas' and libc's, inside its /// heap too: after a big result is formatted or a big pane torn down, the /// tree-sitter arena kept 73 MiB of emptied buckets resident and glibc what |
