This makes build_list() less dependent on the context.
It starts from clean, whatever the state before the call was.
I was having a hard time understanding the reallocation,
until I saw that we were zeroing everything right before the call.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
build_list(char *s, char ***lp, size_t *np)
{
char **l;
- size_t n = *np;
+ size_t n;
+
+ *lp = NULL;
+ n = 0;
while (s != NULL && *s != '\0') {
l = XREALLOC(*lp, n + 1, char *);
sgroup.sg_name = fields[0];
sgroup.sg_passwd = fields[1];
- nadmins = 0;
free (admins);
- admins = NULL;
- nmembers = 0;
free (members);
- members = NULL;
sgroup.sg_adm = build_list (fields[2], &admins, &nadmins);
sgroup.sg_mem = build_list (fields[3], &members, &nmembers);