mirror of https://gerrit.osmocom.org/libosmocore
stat_item: Add function to reset stat items and groups
Change-Id: I80fc0ea8865ec4efdcd4c982e69d863275fd9919 Related: SYS#4877
This commit is contained in:
parent
26a9539e18
commit
ea71b439ec
|
@ -16,3 +16,4 @@ gsm API/ABI change add new member to lapd_datalink
|
|||
gsm new API new gsm0808_create_common_id()
|
||||
gb new API new bssgp_tx_bvc_reset2()
|
||||
core new API new rate_ctr_reset(), rate_ctr_group_reset()
|
||||
core new API new osmo_stat_item_reset(), osmo_stat_item_group_reset()
|
||||
|
|
|
@ -114,4 +114,8 @@ static inline int32_t osmo_stat_item_get_last(const struct osmo_stat_item *item)
|
|||
{
|
||||
return item->values[item->last_offs].value;
|
||||
}
|
||||
|
||||
void osmo_stat_item_reset(struct osmo_stat_item *item);
|
||||
void osmo_stat_item_group_reset(struct osmo_stat_item_group *statg);
|
||||
|
||||
/*! @} */
|
||||
|
|
|
@ -356,4 +356,33 @@ int osmo_stat_item_for_each_group(osmo_stat_item_group_handler_t handle_group, v
|
|||
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);
|
||||
}
|
||||
}
|
||||
/*! @} */
|
||||
|
|
Loading…
Reference in New Issue