From f34f0ff4650e4a9dfdbc9047d93b91cb637411c6 Mon Sep 17 00:00:00 2001 From: Muaz Ahmad Date: Fri, 24 Nov 2023 14:59:14 +0500 Subject: [PATCH] args now use a fixed stack buffer instead of using pages --- src/main.zig | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main.zig b/src/main.zig index 2d2c466..9650d2d 100644 --- a/src/main.zig +++ b/src/main.zig @@ -37,7 +37,10 @@ inline fn get_n_jobs(arg: [:0]const u8) !usize { return n; } -fn get_opts(alloc: std.mem.Allocator) !util.Options { +fn get_opts() !util.Options { + var buff: [100]u8 = undefined; + var fba = std.heap.FixedBufferAllocator.init(&buff); + var alloc = fba.allocator(); var args = try std.process.argsWithAllocator(alloc); defer args.deinit(); _ = args.next(); @@ -51,10 +54,10 @@ fn get_opts(alloc: std.mem.Allocator) !util.Options { } pub fn main() !void { - var arg_buff: [100]u8 = undefined; - var arg_fba = std.heap.FixedBufferAllocator.init(&arg_buff); - const alloc = arg_fba.allocator(); + const opts = get_opts(); - const opts = try get_opts(alloc); + var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); + defer arena.deinit(); + std.debug.print("{any}\n", .{opts}); }