Replace malloc+memset with calloc.
This commit is contained in:
parent
8002d1456f
commit
a6dbe6fa0d
@ -270,11 +270,9 @@ _citrus_db_factory_serialize(struct _citrus_db_factory *df, const char *magic,
|
||||
return (0);
|
||||
}
|
||||
/* allocate hash table */
|
||||
depp = malloc(sizeof(*depp) * df->df_num_entries);
|
||||
depp = calloc(df->df_num_entries, sizeof(*depp));
|
||||
if (depp == NULL)
|
||||
return (-1);
|
||||
for (i = 0; i < df->df_num_entries; i++)
|
||||
depp[i] = NULL;
|
||||
|
||||
/* step1: store the entries which are not conflicting */
|
||||
STAILQ_FOREACH(de, &df->df_entries, de_entry) {
|
||||
|
@ -344,9 +344,8 @@ const char
|
||||
{
|
||||
char *buf;
|
||||
|
||||
if ((buf = malloc((size_t)PATH_MAX)) == NULL)
|
||||
if ((buf = calloc((size_t)PATH_MAX, sizeof(*buf))) == NULL)
|
||||
return (NULL);
|
||||
memset((void *)buf, 0, (size_t)PATH_MAX);
|
||||
_citrus_esdb_alias(name, buf, (size_t)PATH_MAX);
|
||||
return (buf);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user