summaryrefslogtreecommitdiff
path: root/src/rollback.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/rollback.zig')
-rw-r--r--src/rollback.zig11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/rollback.zig b/src/rollback.zig
index aebca40d..320e7949 100644
--- a/src/rollback.zig
+++ b/src/rollback.zig
@@ -64,8 +64,10 @@ pub const Epoch = struct {
const Entry = struct { len: usize, alignment: Alignment, epoch: u32, freed: bool = false };
+ const vtable: Allocator.VTable = .{ .alloc = alloc, .resize = resize, .remap = remap, .free = free };
+
pub fn allocator(e: *Epoch) Allocator {
- return .{ .ptr = e, .vtable = &.{ .alloc = alloc, .resize = resize, .remap = remap, .free = free } };
+ return .{ .ptr = e, .vtable = &vtable };
}
pub fn deinit(e: *Epoch) void {
@@ -197,6 +199,13 @@ pub const Epoch = struct {
}
};
+/// Whether `a` is an epoch's: a replica's core, whose texts a copy holds,
+/// so an edit puts a new buffer in place of one and never writes it
+/// (File.replace).
+pub fn isEpoch(a: Allocator) bool {
+ return a.vtable == &Epoch.vtable;
+}
+
pub const Copy = struct {
meta: Allocator = std.heap.c_allocator,
regions: std.ArrayListUnmanaged(Region) = .empty,