]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
metrics: Add a reset store helper function
authorDavid Goulet <dgoulet@torproject.org>
Wed, 5 May 2021 16:57:44 +0000 (12:57 -0400)
committerDavid Goulet <dgoulet@torproject.org>
Wed, 12 May 2021 15:58:25 +0000 (11:58 -0400)
Signed-off-by: David Goulet <dgoulet@torproject.org>
src/lib/metrics/metrics_store.c
src/lib/metrics/metrics_store.h

index 1a520f49212ba7d8fe775e6d25d806931d8e90c4..33b17804384478a3c8bf4d37aa6980358598f6ed 100644 (file)
@@ -144,3 +144,14 @@ metrics_store_get_output(const metrics_format_t fmt,
     // LCOV_EXCL_STOP
   }
 }
+
+/** Reset a store as in free its content. */
+void
+metrics_store_reset(metrics_store_t *store)
+{
+  if (store == NULL) {
+    return;
+  }
+  strmap_free(store->entries, metrics_store_free_void);
+  store->entries = strmap_new();
+}
index 42bc56e8fd9f9ed842a1dc96623d917e5c87a8c3..d85f484bd6b13ff18f257ce2a26542bc25296aca 100644 (file)
@@ -28,6 +28,7 @@ metrics_store_t *metrics_store_new(void);
 metrics_store_entry_t *metrics_store_add(metrics_store_t *store,
                                          metrics_type_t type,
                                          const char *name, const char *help);
+void metrics_store_reset(metrics_store_t *store);
 
 /* Accessors. */
 smartlist_t *metrics_store_get_all(const metrics_store_t *store,