]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
add typed_value_destroy function
authorSvetlana Shmidt <sshmidt@google.com>
Wed, 16 Sep 2020 09:27:22 +0000 (09:27 +0000)
committerSvetlana Shmidt <sshmidt@google.com>
Wed, 16 Sep 2020 09:27:22 +0000 (09:27 +0000)
src/daemon/metric.c
src/daemon/metric.h

index 1fd2c922392b043fae049b16b8e661dd98985fbb..0d784e5dfa193bcec5c8b08d8889e62ac3679c54 100644 (file)
@@ -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.
  *
index 207d92ace8d85183a26dc5736d3dc8018071b8e8..951b3adf80a6277bdf2bdcfe511f41dd413325f3 100644 (file)
@@ -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);