this repo has no description
1//! HeapArena contains a heap allocator arena
2const HeapArena = @This();
3
4const std = @import("std");
5const Allocator = std.mem.Allocator;
6
7arena: *std.heap.ArenaAllocator,
8
9pub fn init(gpa: Allocator) Allocator.Error!HeapArena {
10 const arena = try gpa.create(std.heap.ArenaAllocator);
11 arena.* = .init(gpa);
12 return .{
13 .arena = arena,
14 };
15}
16
17pub fn deinit(self: HeapArena) void {
18 const gpa = self.arena.child_allocator;
19 self.arena.deinit();
20 gpa.destroy(self.arena);
21}
22
23pub fn allocator(self: HeapArena) Allocator {
24 return self.arena.allocator();
25}