]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
lib/isc/stats.c: Use ->references instead of ->refs
authorOndřej Surý <ondrej@sury.org>
Mon, 20 May 2019 14:59:48 +0000 (16:59 +0200)
committerWitold Kręcicki <wpk@isc.org>
Tue, 9 Jul 2019 14:11:14 +0000 (16:11 +0200)
lib/isc/stats.c

index d41e7aa95f910ec7ba431b75743bd44e38661dda..aa20f754021909dfef5adb8edf729442c220c8ed 100644 (file)
@@ -37,7 +37,7 @@ typedef atomic_int_fast64_t isc_stat_t;
 struct isc_stats {
        unsigned int            magic;
        isc_mem_t               *mctx;
-       isc_refcount_t          refs;
+       isc_refcount_t          references;
        int                     ncounters;
        isc_stat_t              *counters;
 };
@@ -45,16 +45,13 @@ struct isc_stats {
 static isc_result_t
 create_stats(isc_mem_t *mctx, int ncounters, isc_stats_t **statsp) {
        isc_stats_t *stats;
-       int i;
 
        REQUIRE(statsp != NULL && *statsp == NULL);
 
        stats = isc_mem_get(mctx, sizeof(*stats));
        stats->counters = isc_mem_get(mctx, sizeof(isc_stat_t) * ncounters);
-       isc_refcount_init(&stats->refs, 1);
-       for (i = 0; i < ncounters; i++) {
-               atomic_init(&stats->counters[i], 0);
-       }
+       isc_refcount_init(&stats->references, 1);
+       memset(stats->counters, 0, sizeof(isc_stat_t) * ncounters);
        stats->mctx = NULL;
        isc_mem_attach(mctx, &stats->mctx);
        stats->ncounters = ncounters;
@@ -69,7 +66,7 @@ isc_stats_attach(isc_stats_t *stats, isc_stats_t **statsp) {
        REQUIRE(ISC_STATS_VALID(stats));
        REQUIRE(statsp != NULL && *statsp == NULL);
 
-       isc_refcount_increment(&stats->refs);
+       isc_refcount_increment(&stats->references);
        *statsp = stats;
 }
 
@@ -82,7 +79,7 @@ isc_stats_detach(isc_stats_t **statsp) {
        stats = *statsp;
        *statsp = NULL;
 
-       if (isc_refcount_decrement(&stats->refs) == 1) {
+       if (isc_refcount_decrement(&stats->references) == 1) {
                isc_mem_put(stats->mctx, stats->counters,
                            sizeof(isc_stat_t) * stats->ncounters);
                isc_mem_putanddetach(&stats->mctx, stats, sizeof(*stats));