metrics: Add a reset store helper function

Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
David Goulet 2021-05-05 12:57:44 -04:00
parent 455471835d
commit 3164e55f01
2 changed files with 12 additions and 0 deletions

View File

@ -144,3 +144,14 @@ metrics_store_get_output(const metrics_format_t fmt,
// LCOV_EXCL_STOP // 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();
}

View File

@ -28,6 +28,7 @@ metrics_store_t *metrics_store_new(void);
metrics_store_entry_t *metrics_store_add(metrics_store_t *store, metrics_store_entry_t *metrics_store_add(metrics_store_t *store,
metrics_type_t type, metrics_type_t type,
const char *name, const char *help); const char *name, const char *help);
void metrics_store_reset(metrics_store_t *store);
/* Accessors. */ /* Accessors. */
smartlist_t *metrics_store_get_all(const metrics_store_t *store, smartlist_t *metrics_store_get_all(const metrics_store_t *store,