const Allocator = @import("std").mem.Allocator; const Self = @This(); allocator: *Allocator, memory: []u8, len: usize, pub fn alloc(allocator: *Allocator, size: usize) !Self { return Self{ .allocator = allocator, .memory = try allocator.alloc(u8, size), .len = 0, }; } pub fn free(self: *Self) void { self.allocator.free(self.memory); self.* = undefined; } pub fn push(self: *Self, node: u8) void { self.memory[self.len] = node; self.len += 1; } pub fn pop(self: *Self) ?u8 { if (self.len < 1) return null; self.len -= 1; return self.memory[self.len]; } pub fn reset(self: *Self) void { self.len = 0; }