Code

write_mongodb plugin: malloc + memset -> calloc
[collectd.git] / src / target_set.c
index a676a3d1326eb06c87f9c46ea334f733a3838939..faad0bf54e35b7d57b2366e60907fdd4cebe7ce6 100644 (file)
@@ -87,13 +87,12 @@ static int ts_create (const oconfig_item_t *ci, void **user_data) /* {{{ */
   int status;
   int i;
 
-  data = malloc (sizeof (*data));
+  data = calloc (1, sizeof (*data));
   if (data == NULL)
   {
-    ERROR ("ts_create: malloc failed.");
+    ERROR ("ts_create: calloc failed.");
     return (-ENOMEM);
   }
-  memset (data, 0, sizeof (*data));
 
   data->host = NULL;
   data->plugin = NULL;