]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/, src/: Rename REALLOCF() => reallocf_T()
authorAlejandro Colomar <alx@kernel.org>
Sat, 15 Nov 2025 20:47:56 +0000 (21:47 +0100)
committerSerge Hallyn <serge@hallyn.com>
Sat, 6 Dec 2025 03:22:45 +0000 (21:22 -0600)
The 'T' in the name notes that this API is a type-safe variant of the
API it wraps.  This makes the names more explicative.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/addgrps.c
lib/alloc/reallocf.h
lib/subordinateio.c
src/newusers.c

index eda3878f40294e4762819fee068a8dd34625e84b..6ab34dcb31a4b915960fd3cdde2914fda684aef8 100644 (file)
@@ -44,7 +44,7 @@ add_groups(const char *list)
        if (gids == NULL)
                return -1;
 
-       gids = REALLOCF(gids, n + strchrscnt(list, ",:") + 1, gid_t);
+       gids = reallocf_T(gids, n + strchrscnt(list, ",:") + 1, gid_t);
        if (gids == NULL)
                return -1;
 
index 009ae79b8763cf0a8f1e87e415a1196a1a228d20..c3522829d6c65d8a5aac8a04b3421b5c951a76e5 100644 (file)
@@ -15,8 +15,9 @@
 #include "sizeof.h"
 
 
-#define REALLOCF(p, n, T)   REALLOCF_(p, n, typeas(T))
-#define REALLOCF_(p, n, T)                                            \
+// reallocf_T - realloc free-on-error type-safe
+#define reallocf_T(p, n, T)   reallocf_T_(p, n, typeas(T))
+#define reallocf_T_(p, n, T)                                          \
 ({                                                                    \
        _Generic(p, T *: (void)0);                                    \
        (T *){reallocarrayf_(p, n, sizeof(T))};                       \
@@ -25,6 +26,7 @@
 #define reallocarrayf_(p, n, size)  reallocarrayf(p, (n) ?: 1, (size) ?: 1)
 
 
+// reallocarrayf - realloc array free-on-error
 ATTR_ALLOC_SIZE(2, 3)
 ATTR_MALLOC(free)
 inline void *reallocarrayf(void *p, size_t nmemb, size_t size);
index f9a845ddfec97e19c16a15a67cb721e0567cafcb..54eb7641393b3424f9d0ba95659e28c459b3eb68 100644 (file)
@@ -962,7 +962,7 @@ static int append_uids(uid_t **uids, const char *owner, int n)
                        return n;
        }
 
-       *uids = REALLOCF(*uids, n + 1, uid_t);
+       *uids = reallocf_T(*uids, n + 1, uid_t);
        if (!*uids)
                return -1;
 
index bde90a3bca87141bf0b12a97eddb87d2b1c2fbe4..2e69f2c99fa29a93504bdf46833a6cd889a88a74 100644 (file)
@@ -1196,9 +1196,9 @@ int main (int argc, char **argv)
 #ifdef USE_PAM
                /* keep the list of user/password for later update by PAM */
                nusers++;
-               lines     = REALLOCF(lines, nusers, intmax_t);
-               usernames = REALLOCF(usernames, nusers, char *);
-               passwords = REALLOCF(passwords, nusers, char *);
+               lines     = reallocf_T(lines, nusers, intmax_t);
+               usernames = reallocf_T(usernames, nusers, char *);
+               passwords = reallocf_T(passwords, nusers, char *);
                if (lines == NULL || usernames == NULL || passwords == NULL) {
                        fprintf(stderr, _("%s: line %jd: %s\n"), Prog, line, strerrno());
                        fail_exit (EXIT_FAILURE, process_selinux);