From 80db4ec3875b0de7f06de769881d6c5d4b713f2d Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Mon, 26 Oct 2015 14:39:08 +0100 Subject: core: Add difference function to osmo_counter The osmo_counter_difference returns the counter value difference since the last call of this function with the given counter object. Sponsored-by: On-Waves ehf --- src/statistics.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/statistics.c b/src/statistics.c index e28541ba..ad069cea 100644 --- a/src/statistics.c +++ b/src/statistics.c @@ -74,3 +74,11 @@ struct osmo_counter *osmo_counter_get_by_name(const char *name) } return NULL; } + +int osmo_counter_difference(struct osmo_counter *ctr) +{ + int delta = ctr->value - ctr->previous; + ctr->previous = ctr->value; + + return delta; +} -- cgit v1.2.3