X-Git-Url: https://the.earth.li/gitweb/?a=blobdiff_plain;f=hash.c;h=f07017a669d7e65342ce81637d801d0548bb9f59;hb=39627dc8919cce4132cd21528f1e3c6c38aeae85;hp=47ec2d8b099446fee0d033c5fad9fc15a5803e28;hpb=e02c731dfbb288c736f2cd09a9b6df0507c59ddd;p=onak.git diff --git a/hash.c b/hash.c index 47ec2d8..f07017a 100644 --- a/hash.c +++ b/hash.c @@ -38,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;