Rely on realloc(NULL, ...) being equivalent to malloc(...)

This is guaranteed by ISO C.  Now that we require ISO C (and even POSIX)
to compile, we can simplify this code.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar 2023-02-04 21:21:36 +01:00 committed by Serge Hallyn
parent 5c5dc75641
commit 0e1d017993

View File

@ -45,14 +45,7 @@ static char **list (char *s)
member name, or terminating NULL). */
if (i >= size) {
size = i + 100; /* at least: i + 1 */
if (members) {
rbuf =
realloc (members, size * sizeof (char *));
} else {
/* for old (before ANSI C) implementations of
realloc() that don't handle NULL properly */
rbuf = malloc (size * sizeof (char *));
}
rbuf = realloc (members, size * sizeof (char *));
if (!rbuf) {
free (members);
members = NULL;