Commit 583ca36e62

Josh Wolfe <thejoshwolfe@gmail.com>
2017-09-28 03:54:43
add reset() method to IncrementingAllocator (#501)
1 parent c03a764
Changed files (1)
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]);