]> granicus.if.org Git - apache/commitdiff
Expose a new cache_hash function to free the hash table.
authorBill Stoddard <stoddard@apache.org>
Fri, 24 May 2002 14:41:08 +0000 (14:41 +0000)
committerBill Stoddard <stoddard@apache.org>
Fri, 24 May 2002 14:41:08 +0000 (14:41 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95264 13f79535-47bb-0310-9956-ffa450edef68

modules/experimental/cache_hash.c
modules/experimental/cache_hash.h
modules/experimental/mod_mem_cache.c

index bf0c2b13761849d55817a0590aa36fdce84f5691..36a245c14f9914fabcc93935200b873d8ecbe886 100644 (file)
@@ -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.
  */
index 0b06fdba81f4c7845ece7547d3f29597208459ce..96537ccc54ab5e8be4a7a0996f989236bd723598 100644 (file)
@@ -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.
index 1aec8bad2789e0ea73587612994aff305f2bcfdb..f800b23795fc0fe9dac20e36ce3eacb6666cc142 100644 (file)
@@ -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);
     }