From 36c498046cc3a20e1f7989ff5335e576eb9db1e8 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 11 May 2015 22:24:01 +0100 Subject: [PATCH] expand: use FUZIX low level readdir functionality --- Applications/V7/cmd/sh/expand.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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)) { -- 2.34.1