From 7ff51bffd1c7fa34429b6c063fac1d4f7db85d9d Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" Date: Mon, 8 Dec 2025 18:13:14 +0100 Subject: [PATCH] sbase-box: Reduce bss size using dynamic memory There are several big buffers that consume a lot of bss memory even when the applications are not used. This patch removes several of them using dynamic memory instead. --- ls.c | 4 +++- xargs.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ls.c b/ls.c index aa95fef..f6ff434 100644 --- a/ls.c +++ b/ls.c @@ -33,7 +33,7 @@ struct entry { static struct { dev_t dev; ino_t ino; -} tree[PATH_MAX]; +} *tree; static int ret = 0; static int Aflag = 0; @@ -371,6 +371,8 @@ main(int argc, char *argv[]) struct entry ent, *dents, *fents; size_t i, ds, fs; + tree = ereallocarray(NULL, PATH_MAX, sizeof(*tree)); + ARGBEGIN { case '1': /* force output to 1 entry per line */ diff --git a/xargs.c b/xargs.c index b3b2a81..d78b8e9 100644 --- a/xargs.c +++ b/xargs.c @@ -29,7 +29,7 @@ static size_t curprocs, maxprocs = 1; static int nerrors; static int nulflag, nflag, pflag, rflag, tflag, xflag, Iflag; static char *argb; -static char *cmd[NARGS]; +static char **cmd; static char *eofstr; static int @@ -259,6 +259,7 @@ main(int argc, char *argv[]) argmaxsz = _POSIX_ARG_MAX; /* Leave some room for environment variables */ argmaxsz -= 4096; + cmd = emalloc(NARGS * sizeof(*cmd)); ARGBEGIN { case '0':