Code

write_tsdb plugin: malloc + memset -> calloc
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Fri, 1 Apr 2016 16:44:47 +0000 (18:44 +0200)
committerRuben Kerkhof <ruben@rubenkerkhof.com>
Fri, 1 Apr 2016 16:44:47 +0000 (18:44 +0200)
src/write_tsdb.c

index c562596b6d753525aafa663ee532d71bcec5d873..0fa6245212fa5311c535b16c9eebec40ff4666c0 100644 (file)
@@ -579,13 +579,12 @@ static int wt_config_tsd(oconfig_item_t *ci)
     char callback_name[DATA_MAX_NAME_LEN];
     int i;
 
-    cb = malloc(sizeof(*cb));
+    cb = calloc(1, sizeof(*cb));
     if (cb == NULL)
     {
-        ERROR("write_tsdb plugin: malloc failed.");
+        ERROR("write_tsdb plugin: calloc failed.");
         return -1;
     }
-    memset(cb, 0, sizeof(*cb));
     cb->sock_fd = -1;
     cb->node = NULL;
     cb->service = NULL;