Replace malloc+memset with calloc.

This commit is contained in:
Tijl Coosemans 2014-06-13 08:28:51 +00:00
parent 165a6674ec
commit 3fc3c30a27
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=267437
2 changed files with 2 additions and 5 deletions

View File

@ -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) {

View File

@ -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);
}