]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/helper/test-hashmap.c
Use new HASHMAP_INIT macro to simplify hashmap initialization
[thirdparty/git.git] / t / helper / test-hashmap.c
index f38706216f44c3c881f1d52b250fe74d5140bb37..36ff07bd4beaefabe5f42d119b0eac26cf3ae8d9 100644 (file)
@@ -110,7 +110,7 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
                                hashmap_add(&map, &entries[i]->ent);
                        }
 
-                       hashmap_free(&map);
+                       hashmap_clear(&map);
                }
        } else {
                /* test map lookups */
@@ -130,7 +130,7 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
                        }
                }
 
-               hashmap_free(&map);
+               hashmap_clear(&map);
        }
 }
 
@@ -151,12 +151,11 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
 int cmd__hashmap(int argc, const char **argv)
 {
        struct strbuf line = STRBUF_INIT;
-       struct hashmap map;
        int icase;
+       struct hashmap map = HASHMAP_INIT(test_entry_cmp, &icase);
 
        /* init hash map */
        icase = argc > 1 && !strcmp("ignorecase", argv[1]);
-       hashmap_init(&map, test_entry_cmp, &icase, 0);
 
        /* process commands from stdin */
        while (strbuf_getline(&line, stdin) != EOF) {
@@ -262,6 +261,6 @@ int cmd__hashmap(int argc, const char **argv)
        }
 
        strbuf_release(&line);
-       hashmap_free_entries(&map, struct test_entry, ent);
+       hashmap_clear_and_free(&map, struct test_entry, ent);
        return 0;
 }