#define NS_STATS_VALID(x) ISC_MAGIC_VALID(x, NS_STATS_MAGIC)
struct ns_stats {
+ /*% Unlocked */
unsigned int magic;
isc_mem_t *mctx;
isc_stats_t *counters;
if (isc_refcount_decrement(&stats->references) == 1) {
isc_stats_detach(&stats->counters);
+ isc_refcount_destroy(&stats->references);
isc_mem_putanddetach(&stats->mctx, stats, sizeof(*stats));
}
}
REQUIRE(statsp != NULL && *statsp == NULL);
stats = isc_mem_get(mctx, sizeof(*stats));
- if (stats == NULL)
- return (ISC_R_NOMEMORY);
-
stats->counters = NULL;
- atomic_init(&stats->references, 1);
+
+ isc_refcount_init(&stats->references, 1);
result = isc_stats_create(mctx, &stats->counters, ncounters);
- if (result != ISC_R_SUCCESS)
- goto clean_mutex;
+ if (result != ISC_R_SUCCESS) {
+ goto clean_mem;
+ }
stats->magic = NS_STATS_MAGIC;
stats->mctx = NULL;
return (ISC_R_SUCCESS);
- clean_mutex:
+ clean_mem:
isc_mem_put(mctx, stats, sizeof(*stats));
return (result);