diff options
author | Eric Anholt <eric@anholt.net> | 2009-11-23 18:32:35 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2009-11-23 18:32:35 -0800 |
commit | 02981c7267b73f7fc088ded4cf6baa835ab540f7 (patch) | |
tree | 8b7639edcd1b5ad5195f30ba0681cfa9c1d40247 | |
parent | 7c7d3e26da0e9e49c3b179403a7b9217d4e9cb18 (diff) |
Fix valgrind complaints, including leaking the table data!
-rw-r--r-- | hash_table.c | 3 | ||||
-rw-r--r-- | tests/delete_and_lookup.c | 2 | ||||
-rw-r--r-- | tests/delete_management.c | 2 | ||||
-rw-r--r-- | tests/insert_and_lookup.c | 2 | ||||
-rw-r--r-- | tests/insert_many.c | 2 | ||||
-rw-r--r-- | tests/random_entry.c | 2 |
6 files changed, 7 insertions, 6 deletions
diff --git a/hash_table.c b/hash_table.c index 87e80d2..01b8ad2 100644 --- a/hash_table.c +++ b/hash_table.c @@ -118,6 +118,7 @@ hash_table_create(int key_equals_function(const void *a, ht->key_equals_function = key_equals_function; ht->table = calloc(ht->size, sizeof(*ht->table)); ht->entries = 0; + ht->deleted_entries = 0; if (ht->table == NULL) { free(ht); @@ -149,7 +150,7 @@ hash_table_destroy(struct hash_table *ht, delete_function(entry); } } - + free(ht->table); free(ht); } diff --git a/tests/delete_and_lookup.c b/tests/delete_and_lookup.c index 0515ed5..8428ccb 100644 --- a/tests/delete_and_lookup.c +++ b/tests/delete_and_lookup.c @@ -69,7 +69,7 @@ main(int argc, char **argv) entry = hash_table_search(ht, hash_str2, str2); assert(strcmp(entry->key, str2) == 0); - hash_table_destroy(NULL, NULL); + hash_table_destroy(ht, NULL); return 0; } diff --git a/tests/delete_management.c b/tests/delete_management.c index 5e3c1e1..cb35cd1 100644 --- a/tests/delete_management.c +++ b/tests/delete_management.c @@ -82,7 +82,7 @@ main(int argc, char **argv) key_value(entry->key) < size); } - hash_table_destroy(NULL, NULL); + hash_table_destroy(ht, NULL); return 0; } diff --git a/tests/insert_and_lookup.c b/tests/insert_and_lookup.c index 9ed036b..cfaa6c1 100644 --- a/tests/insert_and_lookup.c +++ b/tests/insert_and_lookup.c @@ -52,7 +52,7 @@ main(int argc, char **argv) entry = hash_table_search(ht, hash_str2, str2); assert(strcmp(entry->key, str2) == 0); - hash_table_destroy(NULL, NULL); + hash_table_destroy(ht, NULL); return 0; } diff --git a/tests/insert_many.c b/tests/insert_many.c index fc654d8..259818b 100644 --- a/tests/insert_many.c +++ b/tests/insert_many.c @@ -66,7 +66,7 @@ main(int argc, char **argv) assert(key_value(entry->key) == i); } - hash_table_destroy(NULL, NULL); + hash_table_destroy(ht, NULL); return 0; } diff --git a/tests/random_entry.c b/tests/random_entry.c index ec6ba18..747b566 100644 --- a/tests/random_entry.c +++ b/tests/random_entry.c @@ -83,7 +83,7 @@ main(int argc, char **argv) } assert(i != 100); - hash_table_destroy(NULL, NULL); + hash_table_destroy(ht, NULL); return 0; } |