X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fdaemon%2Ftypes_list.c;h=de6fce3eed11e6251aed251041694484072e7e62;hb=91103db5378a036c0e4da9d512f686d9d0096ff7;hp=75a980aa2a9801c2d754362beb1ca2e12642c820;hpb=e460da6b5715e55c57731dcda31a228502b02b5b;p=collectd.git diff --git a/src/daemon/types_list.c b/src/daemon/types_list.c index 75a980aa..de6fce3e 100644 --- a/src/daemon/types_list.c +++ b/src/daemon/types_list.c @@ -29,6 +29,7 @@ #include "plugin.h" #include "configfile.h" +#include "types_list.h" static int parse_ds (data_source_t *dsrc, char *buf, size_t buf_len) { @@ -111,25 +112,27 @@ static void parse_line (char *buf) if (fields[0][0] == '#') return; - ds = (data_set_t *) malloc (sizeof (data_set_t)); + ds = calloc (1, sizeof (*ds)); if (ds == NULL) return; - memset (ds, '\0', sizeof (data_set_t)); - sstrncpy (ds->type, fields[0], sizeof (ds->type)); ds->ds_num = fields_num - 1; ds->ds = (data_source_t *) calloc (ds->ds_num, sizeof (data_source_t)); if (ds->ds == NULL) + { + sfree (ds); return; + } for (i = 0; i < ds->ds_num; i++) if (parse_ds (ds->ds + i, fields[i + 1], strlen (fields[i + 1])) != 0) { - sfree (ds->ds); ERROR ("types_list: parse_line: Cannot parse data source #%zu " "of data set %s", i, ds->type); + sfree (ds->ds); + sfree (ds); return; }