From 2830f5fc32db7767081beb4b1bb275270608fcab Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Sat, 22 May 2021 21:32:23 +0200 Subject: Simplify znk main --- src/znk.zig | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/src/znk.zig b/src/znk.zig index fe66cb5..e59f11d 100644 --- a/src/znk.zig +++ b/src/znk.zig @@ -36,26 +36,11 @@ const usage = \\ ; -var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){}; - pub fn main() anyerror!void { - // Stolen from the Zig compiler - var gpa_need_deinit = false; - const gpa = gpa: { - if (!std.builtin.link_libc) { - gpa_need_deinit = true; - break :gpa &general_purpose_allocator.allocator; - } - // We would prefer to use raw libc allocator here, but cannot - // use it if it won't support the alignment we need. - if (@alignOf(std.c.max_align_t) < @alignOf(i128)) { - break :gpa std.heap.c_allocator; - } - break :gpa std.heap.raw_c_allocator; - }; - defer if (gpa_need_deinit) { - std.debug.assert(!general_purpose_allocator.deinit()); - }; + var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){}; + defer std.debug.assert(!general_purpose_allocator.deinit()); + const gpa = &general_purpose_allocator.allocator; + var arena_instance = std.heap.ArenaAllocator.init(gpa); defer arena_instance.deinit(); const arena = &arena_instance.allocator; -- cgit v1.2.3