daemon: malloc + memset -> calloc
[collectd.git] / src / daemon / meta_data.c
index 1067864..cb8a195 100644 (file)
@@ -84,13 +84,12 @@ static meta_entry_t *md_entry_alloc (const char *key) /* {{{ */
 {
   meta_entry_t *e;
 
-  e = malloc (sizeof (*e));
+  e = calloc (1, sizeof (*e));
   if (e == NULL)
   {
-    ERROR ("md_entry_alloc: malloc failed.");
+    ERROR ("md_entry_alloc: calloc failed.");
     return (NULL);
   }
-  memset (e, 0, sizeof (*e));
 
   e->key = md_strdup (key);
   if (e->key == NULL)
@@ -220,15 +219,13 @@ meta_data_t *meta_data_create (void) /* {{{ */
 {
   meta_data_t *md;
 
-  md = malloc (sizeof (*md));
+  md = calloc (1, sizeof (*md));
   if (md == NULL)
   {
-    ERROR ("meta_data_create: malloc failed.");
+    ERROR ("meta_data_create: calloc failed.");
     return (NULL);
   }
-  memset (md, 0, sizeof (*md));
 
-  md->head = NULL;
   pthread_mutex_init (&md->lock, /* attr = */ NULL);
 
   return (md);