zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 583ca36e62fc13b38348f9c42bbfb9ddd9fceaa0 (tree)
parent c03a76414717274d02280fdaaaceff1ef4151d07
Author: Josh Wolfe <thejoshwolfe@gmail.com>
Date:   Wed, 27 Sep 2017 18:54:43 -0700

add reset() method to IncrementingAllocator (#501)


Diffstat:
Mstd/mem.zig | 4++++
1 file changed, 4 insertions(+), 0 deletions(-)

diff --git 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]);