szn

Bug 345 — std.process.Args.Iterator is a pre-0.16 pattern; should use init.minimal.args.toSlice(arena)

345. Old args iteration pattern

File: src/main.zig:237-248 Severity: MEDIUM Status: ✅ FIXED

Zig 0.16 migration table:

Old (do not use) New (0.16)
std.process.argsAlloc / getArgsAlloc try init.minimal.args.toSlice(arena)

Previous code:

var args: std.ArrayList([]const u8) = .empty;
defer args.deinit(allocator);

var arg_it = try std.process.Args.Iterator.initAllocator(init.minimal.args, allocator);
defer arg_it.deinit();

while (arg_it.next()) |arg| {
    const arg_dupe = try allocator.dupe(u8, arg);
    try args.append(allocator, arg_dupe);
}
defer {
    for (args.items) |arg| {
        allocator.free(arg);
    }
}

Fixed code:

const arena = init.arena.allocator();
const args = try init.minimal.args.toSlice(arena);

All downstream args.items references were replaced with args (the slice has no .items field). The arena owns the arg strings for the lifetime of the process, eliminating N extra heap allocations and the manual free loop.