From eb5611a7703e8226521db5472e110bf95b0d9725 Mon Sep 17 00:00:00 2001 From: Diego Fronza Date: Tue, 5 Nov 2019 17:48:47 -0300 Subject: [PATCH] Change the isc_stat_t type to isc__atomic_statcounter_t The isc_stat_t type was too similar to isc_stats_t type, so the name was changed to something more distinguishable. --- lib/isc/stats.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/isc/stats.c b/lib/isc/stats.c index aa20f75402..255216d138 100644 --- a/lib/isc/stats.c +++ b/lib/isc/stats.c @@ -29,29 +29,31 @@ #define ISC_STATS_VALID(x) ISC_MAGIC_VALID(x, ISC_STATS_MAGIC) #if defined(_WIN32) && !defined(_WIN64) -typedef atomic_int_fast32_t isc_stat_t; + typedef atomic_int_fast32_t isc__atomic_statcounter_t; #else -typedef atomic_int_fast64_t isc_stat_t; + typedef atomic_int_fast64_t isc__atomic_statcounter_t; #endif struct isc_stats { - unsigned int magic; - isc_mem_t *mctx; - isc_refcount_t references; - int ncounters; - isc_stat_t *counters; + unsigned int magic; + isc_mem_t *mctx; + isc_refcount_t references; + int ncounters; + isc__atomic_statcounter_t *counters; }; static isc_result_t create_stats(isc_mem_t *mctx, int ncounters, isc_stats_t **statsp) { isc_stats_t *stats; + size_t counters_alloc_size; REQUIRE(statsp != NULL && *statsp == NULL); stats = isc_mem_get(mctx, sizeof(*stats)); - stats->counters = isc_mem_get(mctx, sizeof(isc_stat_t) * ncounters); + counters_alloc_size = sizeof(isc__atomic_statcounter_t) * ncounters; + stats->counters = isc_mem_get(mctx, counters_alloc_size); isc_refcount_init(&stats->references, 1); - memset(stats->counters, 0, sizeof(isc_stat_t) * ncounters); + memset(stats->counters, 0, counters_alloc_size); stats->mctx = NULL; isc_mem_attach(mctx, &stats->mctx); stats->ncounters = ncounters; @@ -81,7 +83,8 @@ isc_stats_detach(isc_stats_t **statsp) { if (isc_refcount_decrement(&stats->references) == 1) { isc_mem_put(stats->mctx, stats->counters, - sizeof(isc_stat_t) * stats->ncounters); + sizeof(isc__atomic_statcounter_t) * + stats->ncounters); isc_mem_putanddetach(&stats->mctx, stats, sizeof(*stats)); } } -- GitLab