]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Rely on realloc(NULL, ...) being equivalent to malloc(...)
authorAlejandro Colomar <alx@kernel.org>
Sat, 4 Feb 2023 20:21:36 +0000 (21:21 +0100)
committerSerge Hallyn <serge@hallyn.com>
Fri, 24 Feb 2023 02:28:43 +0000 (20:28 -0600)
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>
lib/sgetgrent.c

index 3d7495022cda2046c8db1687ab794590a1325e30..0138f94b14e95b4b1951e743be01d528d0b57d95 100644 (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;