Function reset [src]

Prototype

pub fn reset(self: *FixedBufferAllocator) void

Parameters

self: *FixedBufferAllocator

Example

test reset { var buf: [8]u8 align(@alignOf(u64)) = undefined; var fba = FixedBufferAllocator.init(buf[0..]); const a = fba.allocator(); const X = 0xeeeeeeeeeeeeeeee; const Y = 0xffffffffffffffff; const x = try a.create(u64); x.* = X; try std.testing.expectError(error.OutOfMemory, a.create(u64)); fba.reset(); const y = try a.create(u64); y.* = Y; // we expect Y to have overwritten X. try std.testing.expect(x.* == y.*); try std.testing.expect(y.* == Y); }

Source

pub fn reset(self: *FixedBufferAllocator) void { self.end_index = 0; }