mirror of
https://code.blicky.net/yorhel/ncdu.git
synced 2026-01-12 17:08:39 -09:00
scan: Don't allocate directory iterator on the stack
I had planned to checkout out async functions here so I could avoid recursing onto the stack alltogether, but it's still unclear to me how to safely call into libc from async functions so let's wait for all that to get fleshed out a bit more.
This commit is contained in:
parent
6f07a36923
commit
b96587c25f
1 changed files with 3 additions and 2 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue