From b967d1b1472a683a8bddae4c3a04ce836334f767 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Wed, 18 Jul 2012 19:27:17 +0200 Subject: [PATCH] proc-cache.c: free entries in the hash table. --- proc-cache.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/proc-cache.c b/proc-cache.c index 825f9ce..52b706e 100644 --- a/proc-cache.c +++ b/proc-cache.c @@ -284,13 +284,13 @@ void proc_cache_close() { /* Write hash entries */ for(i=0; i < table.size; i++) { - struct llist *it; + struct llist *it, *n; struct proc_cache_entry *entry = hash_entry(&table, i); if (!entry) continue; - llist_foreach(it, &entry->list) { + llist_foreach_safe(it, n, &entry->list) { struct proc_cache_entry *e; e = llist_entry(it, struct proc_cache_entry, list); @@ -298,9 +298,15 @@ void proc_cache_close() { write_entry(fd, e); hdr.entries++; } + + /* free this entry in the linked list. */ + free(e); } } + /* Now, free the hash table. */ + hash_free(&table); + hdr.entries = htonl(hdr.entries); /* Write header */ @@ -311,6 +317,4 @@ void proc_cache_close() { commit_lock(&lock); release_lock(&lock); - - hash_free(&table); }