diff --git a/src/scan.zig b/src/scan.zig index f56c9e6f1a2ecd1f0b845aac0bd2a33e2a634221..7ec36b10d65d20b2e7aa9e23b633dd5b32237a4c 100644 --- a/src/scan.zig +++ b/src/scan.zig @@ -449,8 +449,9 @@ var active_context: *Context = undefined; // Read and index entries of the given dir. fn scanDir(ctx: *Context, dir: std.fs.Dir, dir_dev: u64) void { - // XXX: The iterator allocates 8k+ bytes on the stack, may want to do heap allocation here? - var it = dir.iterate(); + var it = main.allocator.create(std.fs.Dir.Iterator) catch unreachable; + defer main.allocator.destroy(it); + it.* = dir.iterate(); while(true) { const entry = it.next() catch { ctx.setDirlistError();