From: Alejandro Colomar Date: Sat, 4 Feb 2023 20:21:36 +0000 (+0100) Subject: Rely on realloc(NULL, ...) being equivalent to malloc(...) X-Git-Tag: 4.14.0-rc1~171 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e1d0179939434361b561459ccd009480dc16b7d;p=thirdparty%2Fshadow.git 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 --- diff --git a/lib/sgetgrent.c b/lib/sgetgrent.c index 3d7495022..0138f94b1 100644 --- a/lib/sgetgrent.c +++ b/lib/sgetgrent.c @@ -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;