From 8287889b840154c224e731fcaa9652d4ad6603d8 Mon Sep 17 00:00:00 2001 From: Bill Stoddard Date: Fri, 24 May 2002 14:41:08 +0000 Subject: [PATCH] Expose a new cache_hash function to free the hash table. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95264 13f79535-47bb-0310-9956-ffa450edef68 --- modules/experimental/cache_hash.c | 9 +++++++++ modules/experimental/cache_hash.h | 11 +++++++++++ modules/experimental/mod_mem_cache.c | 3 +++ 3 files changed, 23 insertions(+) diff --git a/modules/experimental/cache_hash.c b/modules/experimental/cache_hash.c index bf0c2b1376..36a245c14f 100644 --- a/modules/experimental/cache_hash.c +++ b/modules/experimental/cache_hash.c @@ -139,6 +139,15 @@ CACHE_DECLARE(cache_hash_t *) cache_hash_make(apr_size_t size) return ht; } +CACHE_DECLARE(void) cache_hash_free(cache_hash_t *ht) +{ + if (ht) { + if (ht->array) { + free (ht->array); + } + free (ht); + } +} /* * Hash iteration functions. */ diff --git a/modules/experimental/cache_hash.h b/modules/experimental/cache_hash.h index 0b06fdba81..96537ccc54 100644 --- a/modules/experimental/cache_hash.h +++ b/modules/experimental/cache_hash.h @@ -105,6 +105,17 @@ typedef struct cache_hash_index_t cache_hash_index_t; */ CACHE_DECLARE(cache_hash_t *) cache_hash_make(apr_size_t size); +/** + * Create a hash table. + * @param *ht Pointer to the hash table to be freed. + * @return void + * @remark The caller should ensure that all objects have been removed + * from the cache prior to calling cache_hash_free(). Objects + * not removed from the cache prior to calling cache_hash_free() + * will be unaccessable. + */ +CACHE_DECLARE(void) cache_hash_free(cache_hash_t *ht); + /** * Associate a value with a key in a hash table. diff --git a/modules/experimental/mod_mem_cache.c b/modules/experimental/mod_mem_cache.c index 1aec8bad27..f800b23795 100644 --- a/modules/experimental/mod_mem_cache.c +++ b/modules/experimental/mod_mem_cache.c @@ -268,6 +268,9 @@ static apr_status_t cleanup_cache_mem(void *sconfv) } } + /* Cache is empty, free the cache table */ + cache_hash_free(co->cacheht); + if (sconf->lock) { apr_thread_mutex_unlock(sconf->lock); } -- 2.40.0