add reset() method to IncrementingAllocator (#501)

This commit is contained in:
Josh Wolfe 2017-09-27 18:54:43 -07:00 committed by Andrew Kelley
parent c03a764147
commit 583ca36e62

View File

@ -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]);