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
diff --git a/src/statistics.c b/src/statistics.c
index e28541b..ad069ce 100644
--- a/src/statistics.c
+++ b/src/statistics.c
@@ -74,3 +74,11 @@
 	}
 	return NULL;
 }
+
+int osmo_counter_difference(struct osmo_counter *ctr)
+{
+	int delta = ctr->value - ctr->previous;
+	ctr->previous = ctr->value;
+
+	return delta;
+}