From 583ca36e62fc13b38348f9c42bbfb9ddd9fceaa0 Mon Sep 17 00:00:00 2001 From: Josh Wolfe Date: Wed, 27 Sep 2017 18:54:43 -0700 Subject: add reset() method to IncrementingAllocator (#501) --- std/mem.zig | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'std') diff --git a/std/mem.zig b/std/mem.zig index 86c7a5a445..c7ebeb0157 100644 --- a/std/mem.zig +++ b/std/mem.zig @@ -94,6 +94,10 @@ pub const IncrementingAllocator = struct { _ = os.posix.munmap(self.bytes.ptr, self.bytes.len); } + fn reset(self: &IncrementingAllocator) { + self.end_index = 0; + } + fn alloc(allocator: &Allocator, n: usize, alignment: usize) -> %[]u8 { const self = @fieldParentPtr(IncrementingAllocator, "allocator", allocator); const addr = @ptrToInt(&self.bytes[self.end_index]); -- cgit v1.2.3