mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-21 17:41:35 -04:00
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.
This commit is contained in:
parent
ed0ecb62e4
commit
80be99d3ac
2 changed files with 10 additions and 42 deletions
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <isc/refcount.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue