Allocate the arg buffer in once place

This commit is contained in:
sin 2014-01-08 20:29:34 +00:00
parent 2d64fa9483
commit 602fd49b53

View File

@ -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:");