From: Nick Mathewson Date: Sat, 12 Dec 2009 06:30:59 +0000 (-0500) Subject: Make rend_cache_entry_free() typecheck when possible. X-Git-Tag: tor-0.2.2.7-alpha~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79f72d0ef6cc3ce7cc92146ed0f0bdc7a4acad1a;p=thirdparty%2Ftor.git Make rend_cache_entry_free() typecheck when possible. --- diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c index a68ee0c501..92a9af78c1 100644 --- a/src/or/rendcommon.c +++ b/src/or/rendcommon.c @@ -778,14 +778,21 @@ rend_cache_init(void) /** Helper: free storage held by a single service descriptor cache entry. */ static void -_rend_cache_entry_free(void *p) +rend_cache_entry_free(rend_cache_entry_t *e) { - rend_cache_entry_t *e = p; + if (!e) + return; rend_service_descriptor_free(e->parsed); tor_free(e->desc); tor_free(e); } +static void +_rend_cache_entry_free(void *p) +{ + rend_cache_entry_free(p); +} + /** Free all storage held by the service descriptor cache. */ void rend_cache_free_all(void) @@ -814,7 +821,7 @@ rend_cache_clean(void) ent = (rend_cache_entry_t*)val; if (ent->parsed->timestamp < cutoff) { iter = strmap_iter_next_rmv(rend_cache, iter); - _rend_cache_entry_free(ent); + rend_cache_entry_free(ent); } else { iter = strmap_iter_next(rend_cache, iter); } @@ -842,7 +849,7 @@ rend_cache_clean_v2_descs_as_dir(void) log_info(LD_REND, "Removing descriptor with ID '%s' from cache", safe_str(key_base32)); iter = digestmap_iter_next_rmv(rend_cache_v2_dir, iter); - _rend_cache_entry_free(ent); + rend_cache_entry_free(ent); } else { iter = digestmap_iter_next(rend_cache_v2_dir, iter); }