]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
fix all memoty leaks
authorSvetlana Shmidt <sshmidt@google.com>
Wed, 16 Sep 2020 09:57:50 +0000 (09:57 +0000)
committerSvetlana Shmidt <sshmidt@google.com>
Wed, 16 Sep 2020 09:57:50 +0000 (09:57 +0000)
src/daemon/utils_cache.c
src/daemon/utils_cache.h

index 89354125b2ca68d931bebe7f220382577a55aa09..5d5195834b9bc0623039694c04563d6d970151f2 100644 (file)
@@ -208,6 +208,22 @@ int uc_init(void) {
   return 0;
 } /* int uc_init */
 
+void uc_destroy(void) {
+  void *key;
+  cache_entry_t *ce;
+
+  if (cache_tree == NULL)
+    return;
+
+  while (c_avl_pick(cache_tree, &key, (void**)&ce) == 0) {
+    sfree(key);
+    cache_free(ce);
+  }
+
+  c_avl_destroy(cache_tree);
+  cache_tree = NULL;
+}
+
 int uc_check_timeout(void) {
   struct {
     char *key;
index b23813ad5504d02c50e5fad5bc0e21952cac081c..3f9019110f855a67fe7da5ba7307598c18fbbe20 100644 (file)
@@ -42,6 +42,7 @@
 int uc_init(void);
 int uc_check_timeout(void);
 int uc_update(metric_family_t const *fam);
+void uc_destroy(void);
 
 gauge_t *uc_get_rate_vl(const data_set_t *ds, const value_list_t *vl);
 int uc_get_value_by_name_vl(const char *name, value_t **ret_values,