Fix some allocation bugs, replace everything by arena (#18)

This commit is contained in:
Robin Voetter
2021-08-14 00:57:26 +02:00
parent eb417c6aa0
commit 89e16f69a8
2 changed files with 20 additions and 41 deletions

View File

@@ -185,10 +185,6 @@ fn Renderer(comptime WriterType: type) type {
declarations_by_name: std.StringHashMap(*const reg.DeclarationType),
fn init(writer: WriterType, allocator: *Allocator, registry: *const reg.Registry, id_renderer: *IdRenderer) !Self {
const tags = try allocator.alloc([]const u8, registry.tags.len);
errdefer allocator.free(tags);
for (tags) |*tag, i| tag.* = registry.tags[i].name;
var declarations_by_name = std.StringHashMap(*const reg.DeclarationType).init(allocator);
errdefer declarations_by_name.deinit();
@@ -212,8 +208,6 @@ fn Renderer(comptime WriterType: type) type {
fn deinit(self: *Self) void {
self.declarations_by_name.deinit();
self.allocator.free(self.id_renderer.tags);
self.id_renderer.deinit();
}
fn writeIdentifier(self: Self, id: []const u8) !void {