lib/: Rename CALLOC() => calloc_T()

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>
This commit is contained in:
Alejandro Colomar 2025-11-15 22:08:15 +01:00 committed by Serge Hallyn
parent 0d9193dcf6
commit bc4e3712a6
10 changed files with 13 additions and 12 deletions

View File

@ -14,14 +14,15 @@
#include "sizeof.h"
#define CALLOC(n, T) CALLOC_(n, typeas(T))
#define CALLOC_(n, T) \
// calloc_T - calloc type-safe
#define calloc_T(n, T) calloc_T_(n, typeas(T))
#define calloc_T_(n, T) \
({ \
(T *){calloc(n, sizeof(T))}; \
})
#define XCALLOC(n, T) exit_if_null(CALLOC(n, T))
#define XCALLOC(n, T) exit_if_null(calloc_T(n, T))
#endif // include guard

View File

@ -235,7 +235,7 @@ int find_new_gid (bool sys_group,
*/
/* Create an array to hold all of the discovered GIDs */
used_gids = CALLOC (gid_max + 1, bool);
used_gids = calloc_T(gid_max + 1, bool);
if (NULL == used_gids) {
fprintf (log_get_logfd(),
_("%s: failed to allocate memory: %s\n"),

View File

@ -234,7 +234,7 @@ int find_new_uid(bool sys_user,
*/
/* Create an array to hold all of the discovered UIDs */
used_uids = CALLOC(uid_max + 1, bool);
used_uids = calloc_T(uid_max + 1, bool);
if (NULL == used_uids) {
fprintf (log_get_logfd(),
_("%s: failed to allocate memory: %s\n"),

View File

@ -344,7 +344,7 @@ static /*@null@*/struct commonio_entry *merge_group_entries (
members++;
}
}
new_members = CALLOC (members + 1, char *);
new_members = calloc_T(members + 1, char *);
if (NULL == new_members) {
free(new_line);
return NULL;

View File

@ -25,7 +25,7 @@
struct group *gr;
int i;
gr = CALLOC(1, struct group);
gr = calloc_T(1, struct group);
if (NULL == gr) {
return NULL;
}

View File

@ -47,7 +47,7 @@ get_map_ranges(int ranges, int argc, char **argv)
return NULL;
}
mappings = CALLOC(ranges, struct map_range);
mappings = calloc_T(ranges, struct map_range);
if (!mappings) {
fprintf(log_get_logfd(), _( "%s: Memory allocation failure\n"),
log_get_progname());

View File

@ -49,7 +49,7 @@ static int ni_conv (int num_msg,
return PAM_CONV_ERR;
}
responses = CALLOC (num_msg, struct pam_response);
responses = calloc_T(num_msg, struct pam_response);
if (NULL == responses) {
return PAM_CONV_ERR;
}

View File

@ -25,7 +25,7 @@
{
struct passwd *pw;
pw = CALLOC (1, struct passwd);
pw = calloc_T(1, struct passwd);
if (NULL == pw) {
return NULL;
}

View File

@ -34,7 +34,7 @@
struct sgrp *sg;
int i;
sg = CALLOC (1, struct sgrp);
sg = calloc_T(1, struct sgrp);
if (NULL == sg) {
return NULL;
}

View File

@ -26,7 +26,7 @@
{
struct spwd *sp;
sp = CALLOC (1, struct spwd);
sp = calloc_T(1, struct spwd);
if (NULL == sp) {
return NULL;
}