version 1.174, 2022/02/11 00:43:56 |
version 1.175, 2022/03/20 08:51:21 |
|
|
r = vasprintf(&cp, fmt, ap); |
r = vasprintf(&cp, fmt, ap); |
va_end(ap); |
va_end(ap); |
if (r == -1) |
if (r == -1) |
fatal("addargs: argument too long"); |
fatal_f("argument too long"); |
|
|
nalloc = args->nalloc; |
nalloc = args->nalloc; |
if (args->list == NULL) { |
if (args->list == NULL) { |
nalloc = 32; |
nalloc = 32; |
args->num = 0; |
args->num = 0; |
} else if (args->num+2 >= nalloc) |
} else if (args->num > (256 * 1024)) |
|
fatal_f("too many arguments"); |
|
else if (args->num >= args->nalloc) |
|
fatal_f("arglist corrupt"); |
|
else if (args->num+2 >= nalloc) |
nalloc *= 2; |
nalloc *= 2; |
|
|
args->list = xrecallocarray(args->list, args->nalloc, nalloc, sizeof(char *)); |
args->list = xrecallocarray(args->list, args->nalloc, |
|
nalloc, sizeof(char *)); |
args->nalloc = nalloc; |
args->nalloc = nalloc; |
args->list[args->num++] = cp; |
args->list[args->num++] = cp; |
args->list[args->num] = NULL; |
args->list[args->num] = NULL; |
|
|
r = vasprintf(&cp, fmt, ap); |
r = vasprintf(&cp, fmt, ap); |
va_end(ap); |
va_end(ap); |
if (r == -1) |
if (r == -1) |
fatal("replacearg: argument too long"); |
fatal_f("argument too long"); |
|
if (args->list == NULL || args->num >= args->nalloc) |
|
fatal_f("arglist corrupt"); |
|
|
if (which >= args->num) |
if (which >= args->num) |
fatal("replacearg: tried to replace invalid arg %d >= %d", |
fatal_f("tried to replace invalid arg %d >= %d", |
which, args->num); |
which, args->num); |
free(args->list[which]); |
free(args->list[which]); |
args->list[which] = cp; |
args->list[which] = cp; |
|
|
{ |
{ |
u_int i; |
u_int i; |
|
|
if (args->list != NULL) { |
if (args == NULL) |
|
return; |
|
if (args->list != NULL && args->num < args->nalloc) { |
for (i = 0; i < args->num; i++) |
for (i = 0; i < args->num; i++) |
free(args->list[i]); |
free(args->list[i]); |
free(args->list); |
free(args->list); |
args->nalloc = args->num = 0; |
|
args->list = NULL; |
|
} |
} |
|
args->nalloc = args->num = 0; |
|
args->list = NULL; |
} |
} |
|
|
/* |
/* |