diff --git a/.gitignore b/.gitignore index 5471b3c..064e58b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ haggis config.mk test/output/ -test/ +test/* +!test/*.c +!test/Makefile *.o *.a *.so diff --git a/linkmap.c b/linkmap.c index 54ad321..726c60a 100644 --- a/linkmap.c +++ b/linkmap.c @@ -33,6 +33,7 @@ #include "haggis_private.h" #include // PATH_MAX +#include #include // calloc, free #include // strndup @@ -113,7 +114,7 @@ void haggis_linkmap_deinit(haggis_linkmap *map) { int i; for (i = 0; i < map->capacity; i++) { - if (map->buckets[i].next == NULL) { + if (map->buckets[i].next != NULL) { haggis_bucket_deinit(map->buckets[i].next); } } diff --git a/test/Makefile b/test/Makefile index 5885f3d..93d8e8a 100644 --- a/test/Makefile +++ b/test/Makefile @@ -61,6 +61,7 @@ tests += store_file_sha256 tests += load_file_sha256 tests += fnv1a_hash_inode tests += fnv1a_hash_str +tests += linkmap_init total != echo $(tests) | wc -w | awk '{ print $$1 }' diff --git a/test/linkmap_init.c b/test/linkmap_init.c new file mode 100644 index 0000000..15a48df --- /dev/null +++ b/test/linkmap_init.c @@ -0,0 +1,13 @@ +#include +#include + +#include "haggis.h" +#include "haggis_private.h" + +int main() { + haggis_linkmap *map; + + map = haggis_linkmap_init(); + assert(map != NULL); + haggis_linkmap_deinit(map); +}