X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Ffilecount.c;h=c81fdc250c9840901cafeb2f7a09098963bed105;hb=c6557cb8950f50a41a1decfb34439b060e2fd371;hp=47caf93f264af693e0e011634abbf62345b62908;hpb=24c2f247f6dc5c17b26d715346a380efababb08f;p=collectd.git diff --git a/src/filecount.c b/src/filecount.c index 47caf93f..c81fdc25 100644 --- a/src/filecount.c +++ b/src/filecount.c @@ -23,7 +23,7 @@ #include "collectd.h" #include "common.h" -#include "plugin.h" +#include "plugin.h" #include #include @@ -344,18 +344,18 @@ static int fc_config_add_dir (oconfig_item_t *ci) } /* Initialize `dir' */ - dir = (fc_directory_conf_t *) malloc (sizeof (*dir)); + dir = calloc (1, sizeof (*dir)); if (dir == NULL) { - ERROR ("filecount plugin: malloc failed."); + ERROR ("filecount plugin: calloc failed."); return (-1); } - memset (dir, 0, sizeof (*dir)); dir->path = strdup (ci->values[0].value.string); if (dir->path == NULL) { ERROR ("filecount plugin: strdup failed."); + sfree (dir); return (-1); } @@ -399,7 +399,7 @@ static int fc_config_add_dir (oconfig_item_t *ci) { fc_directory_conf_t **temp; - temp = (fc_directory_conf_t **) realloc (directories, + temp = realloc (directories, sizeof (*directories) * (directories_num + 1)); if (temp == NULL) { @@ -541,7 +541,7 @@ static int fc_read_dir (fc_directory_conf_t *dir) if (dir->mtime != 0) dir->now = time (NULL); - + status = walk_directory (dir->path, fc_read_dir_callback, dir, /* include hidden */ (dir->options & FC_HIDDEN) ? 1 : 0); if (status != 0)