diff --git a/xargs.c b/xargs.c index cecba80..7742be2 100644 --- a/xargs.c +++ b/xargs.c @@ -25,7 +25,7 @@ static void spawn(void); static char **cmd; static char *argb; -static size_t argbsz = 1; +static size_t argbsz; static size_t argbpos; static int nerrors = 0; static char *eofstr; @@ -65,10 +65,6 @@ main(int argc, char *argv[]) if (!cmd) eprintf("malloc:"); - argb = malloc(argbsz); - if (!argb) - eprintf("malloc:"); - do { argsz = 0; i = 0; if (argc > 0) { @@ -135,7 +131,7 @@ static void fillargbuf(int ch) { if (argbpos >= argbsz) { - argbsz *= 2; + argbsz = argbpos == 0 ? 1 : argbsz * 2; argb = realloc(argb, argbsz); if (!argb) eprintf("realloc:");