libselinux: simplify zeroing allocation

Merge malloc(3) plus memset(3) call into calloc(3).

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
Christian Göttsche 2023-08-09 19:54:58 +02:00 committed by James Carter
parent b4007663c5
commit 92b1e5b660
1 changed files with 2 additions and 4 deletions

View File

@ -716,10 +716,9 @@ static int selabel_subs_init(const char *path, struct selabel_digest *digest,
if (! *dst)
continue;
sub = malloc(sizeof(*sub));
sub = calloc(1, sizeof(*sub));
if (! sub)
goto err;
memset(sub, 0, sizeof(*sub));
sub->src = strdup(src);
if (! sub->src)
@ -1357,10 +1356,9 @@ int selabel_file_init(struct selabel_handle *rec,
{
struct saved_data *data;
data = (struct saved_data *)malloc(sizeof(*data));
data = (struct saved_data *)calloc(1, sizeof(*data));
if (!data)
return -1;
memset(data, 0, sizeof(*data));
rec->data = data;
rec->func_close = &closef;