stat_item: Add function to reset stat items and groups
Change-Id: I80fc0ea8865ec4efdcd4c982e69d863275fd9919
Related: SYS#4877
diff --git a/src/stat_item.c b/src/stat_item.c
index 6716575..ba36464 100644
--- a/src/stat_item.c
+++ b/src/stat_item.c
@@ -356,4 +356,33 @@
return rc;
}
+
+/*! Remove all values of a stat item
+ * \param[in] item stat item to reset
+ */
+void osmo_stat_item_reset(struct osmo_stat_item *item)
+{
+ unsigned int i;
+
+ item->last_offs = item->desc->num_values - 1;
+ item->last_value_index = -1;
+
+ for (i = 0; i <= item->last_offs; i++) {
+ item->values[i].value = item->desc->default_value;
+ item->values[i].id = OSMO_STAT_ITEM_NOVALUE_ID;
+ }
+}
+
+/*! Reset all osmo stat items in a group
+ * \param[in] statg stat item group to reset
+ */
+void osmo_stat_item_group_reset(struct osmo_stat_item_group *statg)
+{
+ int i;
+
+ for (i = 0; i < statg->desc->num_items; i++) {
+ struct osmo_stat_item *item = statg->items[i];
+ osmo_stat_item_reset(item);
+ }
+}
/*! @} */