iconv sync 3/x: FreeBSD SVN 267437
authorJohn Marino <draco@marino.st>
Fri, 3 Jul 2015 21:54:27 +0000 (23:54 +0200)
committerJohn Marino <draco@marino.st>
Sat, 4 Jul 2015 08:19:05 +0000 (10:19 +0200)
Replace malloc+memset with calloc

lib/libc/citrus/citrus_db_factory.c
lib/libc/citrus/citrus_iconv.c

index be68c7d..3e8ffcf 100644 (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) {
index edfea82..51ea5cb 100644 (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);
 }