From: Svetlana Shmidt Date: Wed, 16 Sep 2020 09:27:22 +0000 (+0000) Subject: add typed_value_destroy function X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1ecd35c4a1f8de2af953462531f1e00455e7bc12;p=thirdparty%2Fcollectd.git add typed_value_destroy function --- diff --git a/src/daemon/metric.c b/src/daemon/metric.c index 1fd2c9223..0d784e5df 100644 --- a/src/daemon/metric.c +++ b/src/daemon/metric.c @@ -52,6 +52,12 @@ typed_value_t typed_value_create(value_t val, metric_type_t type) { return tval; } +void typed_value_destroy(typed_value_t val) { + if (val.type == METRIC_TYPE_DISTRIBUTION) { + distribution_destroy(val.value.distribution); + } +} + /* Label names must match the regex `[a-zA-Z_][a-zA-Z0-9_]*`. Label names * beginning with __ are reserved for internal use. * diff --git a/src/daemon/metric.h b/src/daemon/metric.h index 207d92ace..951b3adf8 100644 --- a/src/daemon/metric.h +++ b/src/daemon/metric.h @@ -71,6 +71,9 @@ typed_value_t typed_value_clone(typed_value_t val); * that means that it should be freed */ typed_value_t typed_value_create(value_t val, metric_type_t type); +/* if type is distribution then it will be freed */ +void typed_value_destroy(typed_value_t val); + /* value_marshal_text prints a text representation of v to buf. */ int value_marshal_text(strbuf_t *buf, value_t v, metric_type_t type);