summaryrefslogtreecommitdiffstats
path: root/src/vlib/counter.c
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2020-04-21 17:54:41 +0200
committerNeale Ranns <nranns@cisco.com>2020-04-28 09:39:47 +0000
commita568a19b2956ed8b94b11c2ef041412473dc8442 (patch)
treef67f766c42d24e784148cf298dcb3b583bc9ea78 /src/vlib/counter.c
parentc0e9441e79b63ea09d5b282910d104960d45026d (diff)
stats: add apis to delete simple/combined counters
vlib_free_simple_counter() vlib_free_combined_counter() Frees the name and two dimensional vector from the stats segment. Type: fix Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: If1becf7d09520ba41a3d59e2df94958ecfcf6948
Diffstat (limited to 'src/vlib/counter.c')
-rw-r--r--src/vlib/counter.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/vlib/counter.c b/src/vlib/counter.c
index 8573b794fd9..edba3754da4 100644
--- a/src/vlib/counter.c
+++ b/src/vlib/counter.c
@@ -91,6 +91,20 @@ vlib_validate_simple_counter (vlib_simple_counter_main_t * cm, u32 index)
}
void
+vlib_free_simple_counter (vlib_simple_counter_main_t * cm)
+{
+ int i;
+
+ vlib_stats_delete_cm (cm);
+
+ void *oldheap = vlib_stats_push_heap (cm->counters);
+ for (i = 0; i < vec_len (cm->counters); i++)
+ vec_free (cm->counters[i]);
+ vec_free (cm->counters);
+ clib_mem_set_heap (oldheap);
+}
+
+void
vlib_validate_combined_counter (vlib_combined_counter_main_t * cm, u32 index)
{
vlib_thread_main_t *tm = vlib_get_thread_main ();
@@ -105,6 +119,20 @@ vlib_validate_combined_counter (vlib_combined_counter_main_t * cm, u32 index)
3 /*STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED */ );
}
+void
+vlib_free_combined_counter (vlib_combined_counter_main_t * cm)
+{
+ int i;
+
+ vlib_stats_delete_cm (cm);
+
+ void *oldheap = vlib_stats_push_heap (cm->counters);
+ for (i = 0; i < vec_len (cm->counters); i++)
+ vec_free (cm->counters[i]);
+ vec_free (cm->counters);
+ clib_mem_set_heap (oldheap);
+}
+
u32
vlib_combined_counter_n_counters (const vlib_combined_counter_main_t * cm)
{