mirror of
https://github.com/ziglang/zig.git
synced 2025-12-29 01:23:17 +00:00
add reset() method to IncrementingAllocator (#501)
This commit is contained in:
parent
c03a764147
commit
583ca36e62
@ -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]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user