diff options
author | David Goulet <dgoulet@torproject.org> | 2021-05-05 12:57:44 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2021-05-12 11:58:25 -0400 |
commit | 3164e55f015ffcf3fe4e034befd287e8067ce5b2 (patch) | |
tree | a2f41ff20177683b2d543e70970be6c16fa8193d /src/lib | |
parent | 455471835da35d8ee64e6a2c0a70acb89a003bf4 (diff) | |
download | tor-3164e55f015ffcf3fe4e034befd287e8067ce5b2.tar.gz tor-3164e55f015ffcf3fe4e034befd287e8067ce5b2.zip |
metrics: Add a reset store helper function
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/metrics/metrics_store.c | 11 | ||||
-rw-r--r-- | src/lib/metrics/metrics_store.h | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/metrics/metrics_store.c b/src/lib/metrics/metrics_store.c index 1a520f4921..33b1780438 100644 --- a/src/lib/metrics/metrics_store.c +++ b/src/lib/metrics/metrics_store.c @@ -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(); +} diff --git a/src/lib/metrics/metrics_store.h b/src/lib/metrics/metrics_store.h index 42bc56e8fd..d85f484bd6 100644 --- a/src/lib/metrics/metrics_store.h +++ b/src/lib/metrics/metrics_store.h @@ -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, |