Assume all the short args have optional args so allocate space for the
':'. It's slightly wasteful, but much easier (and the savings in bytes at runtime would be tiny, but the code to do it larger). Submitted by: Sebastian Huber
This commit is contained in:
parent
490e13c140
commit
21fae2d64f
@ -189,7 +189,7 @@ arg_parse(int argc, char * const * argv, const struct cmd *f)
|
||||
lopts = malloc((n + 2) * sizeof(struct option));
|
||||
if (lopts == NULL)
|
||||
err(1, "option memory");
|
||||
p = shortopts = malloc((n + 3) * sizeof(char));
|
||||
p = shortopts = malloc((2 * n + 3) * sizeof(char));
|
||||
if (shortopts == NULL)
|
||||
err(1, "shortopts memory");
|
||||
idx = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user