From: Martti Rannanjärvi Date: Thu, 3 Feb 2022 23:28:45 +0000 (+0200) Subject: stats: stats_metrics_remove_dynamic() - Free the removed metric X-Git-Tag: 2.3.19~72 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ff258ecea5492fe6d40a96a79610d665c2bc1743;p=thirdparty%2Fdovecot%2Fcore.git stats: stats_metrics_remove_dynamic() - Free the removed metric --- diff --git a/src/stats/stats-metrics.c b/src/stats/stats-metrics.c index 85414f6a66..632c4865b6 100644 --- a/src/stats/stats-metrics.c +++ b/src/stats/stats-metrics.c @@ -27,6 +27,7 @@ static void stats_metric_event(struct metric *metric, struct event *event, pool_t pool); static struct metric * stats_metric_sub_metric_alloc(struct metric *metric, const char *name, pool_t pool); +static void stats_metric_free(struct metric *metric); static void stats_exporters_add_set(struct stats_metrics *metrics, const struct stats_exporter_settings *set) @@ -209,12 +210,14 @@ bool stats_metrics_remove_dynamic(struct stats_metrics *metrics, const char *name) { unsigned int m_idx; + bool ret = FALSE; struct metric *m = stats_metrics_find(metrics, name, &m_idx); if (m != NULL) { array_delete(&metrics->metrics, m_idx, 1); - return event_filter_remove_queries_with_context(metrics->filter, m); + ret = event_filter_remove_queries_with_context(metrics->filter, m); + stats_metric_free(m); } - return FALSE; + return ret; } static void