Use reallocf(3) instead of its pattern
In addition, don't set local variables just before return. Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
parent
56e4842db0
commit
45c0003e53
@ -37,7 +37,6 @@ static char **list (char *s)
|
||||
static char **members = NULL;
|
||||
static int size = 0; /* max members + 1 */
|
||||
int i;
|
||||
char **rbuf;
|
||||
|
||||
i = 0;
|
||||
for (;;) {
|
||||
@ -45,14 +44,9 @@ static char **list (char *s)
|
||||
member name, or terminating NULL). */
|
||||
if (i >= size) {
|
||||
size = i + 100; /* at least: i + 1 */
|
||||
rbuf = realloc (members, size * sizeof (char *));
|
||||
if (!rbuf) {
|
||||
free (members);
|
||||
members = NULL;
|
||||
size = 0;
|
||||
members = reallocf (members, size * sizeof (char *));
|
||||
if (!members)
|
||||
return NULL;
|
||||
}
|
||||
members = rbuf;
|
||||
}
|
||||
if (!s || s[0] == '\0')
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user