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,9 +29,9 @@
#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 {
......@@ -39,19 +39,21 @@ struct isc_stats {
isc_mem_t *mctx;
isc_refcount_t references;
int ncounters;
isc_stat_t *counters;
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));
}
}
......
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