args now use a fixed stack buffer instead of using pages

This commit is contained in:
Muaz Ahmad 2023-11-24 14:59:14 +05:00
parent b5e1b15f8c
commit f34f0ff465

View file

@ -37,7 +37,10 @@ inline fn get_n_jobs(arg: [:0]const u8) !usize {
return n; 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); var args = try std.process.argsWithAllocator(alloc);
defer args.deinit(); defer args.deinit();
_ = args.next(); _ = args.next();
@ -51,10 +54,10 @@ fn get_opts(alloc: std.mem.Allocator) !util.Options {
} }
pub fn main() !void { pub fn main() !void {
var arg_buff: [100]u8 = undefined; const opts = get_opts();
var arg_fba = std.heap.FixedBufferAllocator.init(&arg_buff);
const alloc = arg_fba.allocator(); var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const opts = try get_opts(alloc);
std.debug.print("{any}\n", .{opts}); std.debug.print("{any}\n", .{opts});
} }