]> the.earth.li Git - onak.git/blobdiff - hash.c
cscvs to tla changeset 20
[onak.git] / hash.c
diff --git a/hash.c b/hash.c
index 82dfcc7c04a560a2a8508c4486efeebbae1c5d94..f07017a669d7e65342ce81637d801d0548bb9f59 100644 (file)
--- a/hash.c
+++ b/hash.c
@@ -11,6 +11,7 @@
 
 #include "hash.h"
 #include "keydb.h"
+#include "keyid.h"
 #include "ll.h"
 #include "stats.h"
 
@@ -37,6 +38,35 @@ void inithash(void)
        elements = 0;
 }
 
+/**
+ *     destroyhash - Clean up the hash after use.
+ *
+ *     This function destroys the hash after use, freeing any memory that was
+ *     used during its lifetime.
+ */
+void destroyhash(void)
+{
+       int i;
+       struct ll *curll = NULL;
+
+       for (i = 0; i < HASHSIZE; i++) {
+               curll = hashtable[i];
+               /*
+                * TODO: The problem is the object has pointers that
+                * need freed too.
+                */
+               llfree(curll, free);
+               hashtable[i] = NULL;
+       }
+       elements = 0;
+}
+
+/**
+ *     addtohash - Adds a key to the hash.
+ *     @key: The key to add.
+ *
+ *     Takes a key and stores it in the hash.
+ */
 void addtohash(struct stats_key *key)
 {
        ++elements;