sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

commit 7ff51bffd1c7fa34429b6c063fac1d4f7db85d9d
parent 13db2e48d4b7899c04d7fdbc88cab29397b3f44b
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Mon,  8 Dec 2025 18:13:14 +0100

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.

Diffstat:
Mls.c | 4+++-
Mxargs.c | 3++-
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git 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 @@ -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':