Commit eb5611a7 authored by Diego dos Santos Fronza's avatar Diego dos Santos Fronza Committed by Ondřej Surý

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.
parent 0fc98ef2
...@@ -29,29 +29,31 @@ ...@@ -29,29 +29,31 @@
#define ISC_STATS_VALID(x) ISC_MAGIC_VALID(x, ISC_STATS_MAGIC) #define ISC_STATS_VALID(x) ISC_MAGIC_VALID(x, ISC_STATS_MAGIC)
#if defined(_WIN32) && !defined(_WIN64) #if defined(_WIN32) && !defined(_WIN64)
typedef atomic_int_fast32_t isc_stat_t; typedef atomic_int_fast32_t isc__atomic_statcounter_t;
#else #else
typedef atomic_int_fast64_t isc_stat_t; typedef atomic_int_fast64_t isc__atomic_statcounter_t;
#endif #endif
struct isc_stats { struct isc_stats {
unsigned int magic; unsigned int magic;
isc_mem_t *mctx; isc_mem_t *mctx;
isc_refcount_t references; isc_refcount_t references;
int ncounters; int ncounters;
isc_stat_t *counters; isc__atomic_statcounter_t *counters;
}; };
static isc_result_t static isc_result_t
create_stats(isc_mem_t *mctx, int ncounters, isc_stats_t **statsp) { create_stats(isc_mem_t *mctx, int ncounters, isc_stats_t **statsp) {
isc_stats_t *stats; isc_stats_t *stats;
size_t counters_alloc_size;
REQUIRE(statsp != NULL && *statsp == NULL); REQUIRE(statsp != NULL && *statsp == NULL);
stats = isc_mem_get(mctx, sizeof(*stats)); 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); 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; stats->mctx = NULL;
isc_mem_attach(mctx, &stats->mctx); isc_mem_attach(mctx, &stats->mctx);
stats->ncounters = ncounters; stats->ncounters = ncounters;
...@@ -81,7 +83,8 @@ isc_stats_detach(isc_stats_t **statsp) { ...@@ -81,7 +83,8 @@ isc_stats_detach(isc_stats_t **statsp) {
if (isc_refcount_decrement(&stats->references) == 1) { if (isc_refcount_decrement(&stats->references) == 1) {
isc_mem_put(stats->mctx, stats->counters, 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)); isc_mem_putanddetach(&stats->mctx, stats, sizeof(*stats));
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment