counters: add osmo_counters_count() returns the amount of counters

Change-Id: I9068231d71876e06d27ee67a688d7fb611ac3a1b
This commit is contained in:
Alexander Couzens 2017-12-05 16:06:27 +01:00
parent ad1797e359
commit 18ba26cfab
2 changed files with 9 additions and 0 deletions

View File

@ -44,6 +44,8 @@ void osmo_counter_free(struct osmo_counter *ctr);
int osmo_counters_for_each(int (*handle_counter)(struct osmo_counter *, void *), void *data);
int osmo_counters_count();
struct osmo_counter *osmo_counter_get_by_name(const char *name);
int osmo_counter_difference(struct osmo_counter *ctr);

View File

@ -77,6 +77,13 @@ int osmo_counters_for_each(int (*handle_counter)(struct osmo_counter *, void *),
return rc;
}
/*! Counts the registered counter
* \returns amount of counters */
int osmo_counters_count()
{
return llist_count(&counters);
}
/*! Find a counter by its name.
* \param[in] name Name used to look-up/search counter
* \returns Counter on success; NULL if not found */