| ... | @@ -94,6 +94,10 @@ pub const IncrementingAllocator = struct { | ... | @@ -94,6 +94,10 @@ pub const IncrementingAllocator = struct { |
| 94 | _ = os.posix.munmap(self.bytes.ptr, self.bytes.len); | 94 | _ = os.posix.munmap(self.bytes.ptr, self.bytes.len); |
| 95 | } | 95 | } |
| 96 | | 96 | |
| | 97 | fn reset(self: &IncrementingAllocator) { |
| | 98 | self.end_index = 0; |
| | 99 | } |
| | 100 | |
| 97 | fn alloc(allocator: &Allocator, n: usize, alignment: usize) -> %[]u8 { | 101 | fn alloc(allocator: &Allocator, n: usize, alignment: usize) -> %[]u8 { |
| 98 | const self = @fieldParentPtr(IncrementingAllocator, "allocator", allocator); | 102 | const self = @fieldParentPtr(IncrementingAllocator, "allocator", allocator); |
| 99 | const addr = @ptrToInt(&self.bytes[self.end_index]); | 103 | const addr = @ptrToInt(&self.bytes[self.end_index]); |