X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fmatch_empty_counter.c;h=caa3e7e302c000c342775e64665f5aa46ac3c6b0;hb=9a68f99cfe1d2f3013534b3018068f808a6823c4;hp=e30ff91bc7f17e6a9983a9215e53497ea8c78794;hpb=5047407e6c0ca8b53bf1629144396702cd18cf08;p=collectd.git diff --git a/src/match_empty_counter.c b/src/match_empty_counter.c index e30ff91b..caa3e7e3 100644 --- a/src/match_empty_counter.c +++ b/src/match_empty_counter.c @@ -26,7 +26,6 @@ #include "collectd.h" #include "common.h" -#include "utils_cache.h" #include "filter_chain.h" /* @@ -46,13 +45,12 @@ static int mec_create (const oconfig_item_t *ci, void **user_data) /* {{{ */ { mec_match_t *m; - m = (mec_match_t *) malloc (sizeof (*m)); + m = calloc (1, sizeof (*m)); if (m == NULL) { - ERROR ("mec_create: malloc failed."); + ERROR ("mec_create: calloc failed."); return (-ENOMEM); } - memset (m, 0, sizeof (*m)); if (ci->children_num != 0) { @@ -91,11 +89,13 @@ static int mec_match (const data_set_t __attribute__((unused)) *ds, /* {{{ */ for (i = 0; i < ds->ds_num; i++) { - if (ds->ds[i].type != DS_TYPE_COUNTER) + if ((ds->ds[i].type != DS_TYPE_DERIVE) + && (ds->ds[i].type != DS_TYPE_COUNTER)) continue; num_counters++; - if (vl->values[i].counter == 0) + if (((ds->ds[i].type == DS_TYPE_DERIVE) && (vl->values[i].derive == 0)) + || ((ds->ds[i].type == DS_TYPE_COUNTER) && (vl->values[i].counter == 0))) num_empty++; }