diff options
author | David Goulet <dgoulet@torproject.org> | 2016-09-16 16:39:01 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2016-11-04 10:32:50 -0400 |
commit | 1eed6edf36d57c5f80a13a6884afda798fa2abcd (patch) | |
tree | 7cf283ba715f424153f9332bf5f48ece54f57f2e /src/or/hs_cache.c | |
parent | 3f29688bdff3d6aa0b47ee7080995f44dbb579de (diff) | |
download | tor-1eed6edf36d57c5f80a13a6884afda798fa2abcd.tar.gz tor-1eed6edf36d57c5f80a13a6884afda798fa2abcd.zip |
prop224: Add a cache free all function
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/hs_cache.c')
-rw-r--r-- | src/or/hs_cache.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/or/hs_cache.c b/src/or/hs_cache.c index ec98b47f84..868f936422 100644 --- a/src/or/hs_cache.c +++ b/src/or/hs_cache.c @@ -56,6 +56,15 @@ cache_dir_desc_free(hs_cache_dir_descriptor_t *desc) tor_free(desc); } +/* Helper function: Use by the free all function using the digest256map + * interface to cache entries. */ +static void +cache_dir_desc_free_(void *ptr) +{ + hs_cache_dir_descriptor_t *desc = ptr; + cache_dir_desc_free(desc); +} + /* Create a new directory cache descriptor object from a encoded descriptor. * On success, return the heap-allocated cache object, otherwise return NULL if * we can't decode the descriptor. */ @@ -366,3 +375,10 @@ hs_cache_init(void) hs_cache_v3_dir = digest256map_new(); } +/* Cleanup the hidden service cache subsystem. */ +void +hs_cache_free_all(void) +{ + tor_assert(hs_cache_v3_dir); + digest256map_free(hs_cache_v3_dir, cache_dir_desc_free_); +} |