mirror of
https://github.com/shadow-maint/shadow.git
synced 2026-01-26 22:12:26 +00:00
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:
parent
0d9193dcf6
commit
bc4e3712a6
@ -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
|
||||
|
||||
@ -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"),
|
||||
|
||||
@ -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"),
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
{
|
||||
struct passwd *pw;
|
||||
|
||||
pw = CALLOC (1, struct passwd);
|
||||
pw = calloc_T(1, struct passwd);
|
||||
if (NULL == pw) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
{
|
||||
struct spwd *sp;
|
||||
|
||||
sp = CALLOC (1, struct spwd);
|
||||
sp = calloc_T(1, struct spwd);
|
||||
if (NULL == sp) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user