Skip to content
Snippets Groups Projects
Commit b96587c2 authored by Yorhel's avatar Yorhel
Browse files

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.
parent 6f07a369
No related branches found
No related tags found
No related merge requests found
...@@ -449,8 +449,9 @@ var active_context: *Context = undefined; ...@@ -449,8 +449,9 @@ var active_context: *Context = undefined;
// Read and index entries of the given dir. // Read and index entries of the given dir.
fn scanDir(ctx: *Context, dir: std.fs.Dir, dir_dev: u64) void { 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 = main.allocator.create(std.fs.Dir.Iterator) catch unreachable;
var it = dir.iterate(); defer main.allocator.destroy(it);
it.* = dir.iterate();
while(true) { while(true) {
const entry = it.next() catch { const entry = it.next() catch {
ctx.setDirlistError(); ctx.setDirlistError();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment