From: Alessio Podda Date: Wed, 25 Mar 2026 09:22:32 +0000 (+0100) Subject: Convert isc_statsmulti to use ISC_REFCOUNT_IMPL X-Git-Tag: v9.21.21~9^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80be99d3ac4bcba7352d831ed114efe1950698f2;p=thirdparty%2Fbind9.git Convert isc_statsmulti to use ISC_REFCOUNT_IMPL Instead of using hand-rolled attach and detach function, this commit declares the same functions through the ISC_REFCOUNT_IMPL macro. --- diff --git a/lib/isc/include/isc/statsmulti.h b/lib/isc/include/isc/statsmulti.h index 7785662d842..ce504924b81 100644 --- a/lib/isc/include/isc/statsmulti.h +++ b/lib/isc/include/isc/statsmulti.h @@ -17,6 +17,7 @@ #include +#include #include typedef struct isc_statsmulti isc_statsmulti_t; /*%< Statistics Multi */ @@ -44,25 +45,7 @@ isc_statsmulti_create(isc_mem_t *mctx, isc_statsmulti_t **statsp, *\li 'statsp' != NULL && '*statsp' == NULL. */ -void -isc_statsmulti_attach(isc_statsmulti_t *stats, isc_statsmulti_t **statsp); -/*%< - * Attach to a statistics set. - * - * Requires: - *\li 'stats' is a valid isc_statsmulti_t. - * - *\li 'statsp' != NULL && '*statsp' == NULL - */ - -void -isc_statsmulti_detach(isc_statsmulti_t **statsp); -/*%< - * Detaches from the statistics set. - * - * Requires: - *\li 'statsp' != NULL and '*statsp' is a valid isc_statsmulti_t. - */ +ISC_REFCOUNT_DECL(isc_statsmulti); void isc_statsmulti_increment(isc_statsmulti_t *stats, isc_statscounter_t counter); diff --git a/lib/isc/statsmulti.c b/lib/isc/statsmulti.c index 70f99182628..f509f481148 100644 --- a/lib/isc/statsmulti.c +++ b/lib/isc/statsmulti.c @@ -84,33 +84,18 @@ isc_statsmulti_create(isc_mem_t *mctx, isc_statsmulti_t **statsp, *statsp = stats; } -void -isc_statsmulti_attach(isc_statsmulti_t *stats, isc_statsmulti_t **statsp) { +static void +isc__statsmulti_destroy(isc_statsmulti_t *stats) { REQUIRE(ISC_STATSMULTI_VALID(stats)); - REQUIRE(statsp != NULL && *statsp == NULL); - isc_refcount_increment(&stats->references); - *statsp = stats; + size_t alloc_size = stats->per_thread_capacity * + stats->num_threads_plus_one * + sizeof(isc_atomic_statscounter_t); + isc_mem_put(stats->mctx, stats->counters, alloc_size); + isc_mem_putanddetach(&stats->mctx, stats, sizeof(*stats)); } -void -isc_statsmulti_detach(isc_statsmulti_t **statsp) { - isc_statsmulti_t *stats; - - REQUIRE(statsp != NULL && ISC_STATSMULTI_VALID(*statsp)); - - stats = *statsp; - *statsp = NULL; - - if (isc_refcount_decrement(&stats->references) == 1) { - isc_refcount_destroy(&stats->references); - size_t alloc_size = stats->per_thread_capacity * - stats->num_threads_plus_one * - sizeof(isc_atomic_statscounter_t); - isc_mem_put(stats->mctx, stats->counters, alloc_size); - isc_mem_putanddetach(&stats->mctx, stats, sizeof(*stats)); - } -} +ISC_REFCOUNT_IMPL(isc_statsmulti, isc__statsmulti_destroy); void isc_statsmulti_increment(isc_statsmulti_t *stats, isc_statscounter_t counter) {