diff options
author | Harald Welte <laforge@osmocom.org> | 2023-03-23 21:59:03 +0100 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2023-03-24 14:08:08 +0100 |
commit | 8969298a7755db2df4d3f824ca82f1c31d65380a (patch) | |
tree | 493967d9d8da1521f91e070e75181c8905cc2289 /include | |
parent | 5e3aaf9f0db220d9e730c4317869e264cac52f24 (diff) |
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
Diffstat (limited to 'include')
-rw-r--r-- | include/osmocom/core/rate_ctr.h | 9 |
1 files changed, 9 insertions, 0 deletions
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) |