From: Alan Cox Date: Mon, 11 May 2015 21:24:01 +0000 (+0100) Subject: expand: use FUZIX low level readdir functionality X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=36c498046cc3a20e1f7989ff5335e576eb9db1e8;p=FUZIX.git expand: use FUZIX low level readdir functionality --- diff --git a/Applications/V7/cmd/sh/expand.c b/Applications/V7/cmd/sh/expand.c index e4683369..ba93010d 100644 --- a/Applications/V7/cmd/sh/expand.c +++ b/Applications/V7/cmd/sh/expand.c @@ -37,8 +37,9 @@ int expand(char *as, int rflg) STRING rescan = 0; register char *s, *cs; ARGPTR schain = gchain; - struct dirent entry; STATBUF statb; + /* Use the internal API to avoid sucking in readdir and thus malloc */ + struct __dirent entry; if (trapnote & SIGSET) return (0); @@ -96,8 +97,9 @@ int expand(char *as, int rflg) } } while (*rs++); - // FIXME: readdir - while (read(dirf, (void *) &entry, 32) == 32 && (trapnote & SIGSET) == 0) { + /* We don't want to use opendir as it uses calloc and sucks in malloc so we get + down and dirty */ + while (_getdirent(dirf, (void *) &entry, 32) == 32 && (trapnote & SIGSET) == 0) { if (entry.d_ino == 0 || (*entry.d_name == '.' && *cs != '.')) continue; if (gmatch(entry.d_name, cs)) {