X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdaemon%2Futils_tail_match.c;h=604c6d4ca0ba782cd76e3e0cda717d53cb8d7883;hb=6fd0d2574fc386c2724c8307d33b12529b30048b;hp=8776ad11f3731f6596f5f7ee078c78c97cec53d6;hpb=cf33da9ad00ac94931a2c87563f8d007a996f1ad;p=collectd.git diff --git a/src/daemon/utils_tail_match.c b/src/daemon/utils_tail_match.c index 8776ad11..604c6d4c 100644 --- a/src/daemon/utils_tail_match.c +++ b/src/daemon/utils_tail_match.c @@ -30,6 +30,7 @@ */ #include "collectd.h" + #include "common.h" #include "plugin.h" #include "utils_match.h" @@ -126,10 +127,9 @@ cu_tail_match_t *tail_match_create (const char *filename) { cu_tail_match_t *obj; - obj = (cu_tail_match_t *) malloc (sizeof (cu_tail_match_t)); + obj = calloc (1, sizeof (*obj)); if (obj == NULL) return (NULL); - memset (obj, '\0', sizeof (cu_tail_match_t)); obj->tail = cu_tail_create (filename); if (obj->tail == NULL) @@ -180,7 +180,7 @@ int tail_match_add_match (cu_tail_match_t *obj, cu_match_t *match, { cu_tail_match_match_t *temp; - temp = (cu_tail_match_match_t *) realloc (obj->matches, + temp = realloc (obj->matches, sizeof (cu_tail_match_match_t) * (obj->matches_num + 1)); if (temp == NULL) return (-1); @@ -212,13 +212,12 @@ int tail_match_add_match_simple (cu_tail_match_t *obj, if (match == NULL) return (-1); - user_data = (cu_tail_match_simple_t *) malloc (sizeof (cu_tail_match_simple_t)); + user_data = calloc (1, sizeof (*user_data)); if (user_data == NULL) { match_destroy (match); return (-1); } - memset (user_data, '\0', sizeof (cu_tail_match_simple_t)); sstrncpy (user_data->plugin, plugin, sizeof (user_data->plugin)); if (plugin_instance != NULL)