diff --git a/src/he4.c b/src/he4.c index 1c4b8c1..df96b95 100644 --- a/src/he4.c +++ b/src/he4.c @@ -264,11 +264,11 @@ he4_delete(HE4 * table) { } // Delete any remaining entries. - table->free = 0; - table->capacity = 0; for (size_t index = 0; index < table->capacity; ++index) { empty_cell(table, index, true, true); } // Delete any remaining entries. + table->free = 0; + table->capacity = 0; // Wipe the method table. table->compare = NULL; diff --git a/tests/insert-2-test.c b/tests/insert-2-test.c index 22a1160..8a089dd 100644 --- a/tests/insert-2-test.c +++ b/tests/insert-2-test.c @@ -179,6 +179,7 @@ START_ITEM(cleanup) } free(entry); free(rval); + free(pentry); --size; ASSERT(he4_size(table) == size); } // Check for bad items. diff --git a/tests/insert-test.c b/tests/insert-test.c index 1832e58..e9f0bcd 100644 --- a/tests/insert-test.c +++ b/tests/insert-test.c @@ -84,9 +84,11 @@ START_ITEM(insert) } // Test over-filling. // Verify that none of the bad items made it in. for (size_t index = 0; index < he4_size(table); ++index) { - if (he4_index(table, index)->entry > 2047) { + he4_map_t * map = he4_index(table, index); + if (map->entry > 2047) { FAIL_ITEM("found bad item with index: %zu", index); } + HE4FREE(map); } // Check for bad items. ASSERT(he4_capacity(table) == 1024); IF_FAIL_STOP; ASSERT(he4_size(table) == 1024); IF_FAIL_STOP; @@ -125,6 +127,7 @@ START_ITEM(cleanup) } --size; ASSERT(he4_size(table) == size); + HE4FREE(pentry); } // Check for bad items. ASSERT(he4_capacity(table) == 1024); IF_FAIL_STOP; ASSERT(he4_size(table) == 0); IF_FAIL_STOP;