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 char **members = NULL;
|
||||||
static int size = 0; /* max members + 1 */
|
static int size = 0; /* max members + 1 */
|
||||||
int i;
|
int i;
|
||||||
char **rbuf;
|
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -45,14 +44,9 @@ static char **list (char *s)
|
|||||||
member name, or terminating NULL). */
|
member name, or terminating NULL). */
|
||||||
if (i >= size) {
|
if (i >= size) {
|
||||||
size = i + 100; /* at least: i + 1 */
|
size = i + 100; /* at least: i + 1 */
|
||||||
rbuf = realloc (members, size * sizeof (char *));
|
members = reallocf (members, size * sizeof (char *));
|
||||||
if (!rbuf) {
|
if (!members)
|
||||||
free (members);
|
|
||||||
members = NULL;
|
|
||||||
size = 0;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
members = rbuf;
|
|
||||||
}
|
}
|
||||||
if (!s || s[0] == '\0')
|
if (!s || s[0] == '\0')
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user