From 8969298a7755db2df4d3f824ca82f1c31d65380a Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 23 Mar 2023 21:59:03 +0100 Subject: rate_ctr: Add rate_ctr_add2() similar to rate_ctr_inc2() The convenience wrapper relieves the caller from manually resolving the individual counter, and instead specify just the counter group and the index. Change-Id: If93e8b4fb0b86a87358f32d2b45438ca1887e9f3 --- include/osmocom/core/rate_ctr.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/osmocom/core/rate_ctr.h b/include/osmocom/core/rate_ctr.h index d944cc0c..0a3eb2ce 100644 --- a/include/osmocom/core/rate_ctr.h +++ b/include/osmocom/core/rate_ctr.h @@ -86,6 +86,15 @@ void rate_ctr_group_free(struct rate_ctr_group *grp); * \param inc quantity to increment \a ctr by */ void rate_ctr_add(struct rate_ctr *ctr, int inc); +/*! Increment the counter by \a inc + * \param ctrg \ref rate_ctr_group of counter + * \param idx index into \a ctrg counter group + * \param inc quantity to increment \a ctr by */ +static inline void rate_ctr_add2(struct rate_ctr_group *ctrg, unsigned int idx, int inc) +{ + rate_ctr_add(rate_ctr_group_get_ctr(ctrg, idx), inc); +} + /*! Increment the counter by 1 * \param ctr \ref rate_ctr to increment */ static inline void rate_ctr_inc(struct rate_ctr *ctr) -- cgit v1.2.3