]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/helper/test-hashmap.c
Merge branch 'js/update-index-ignore-removal-for-skip-worktree'
[thirdparty/git.git] / t / helper / test-hashmap.c
index 07a93a2aec243afe3bd2d4a3f09a899f4fc8a709..f38706216f44c3c881f1d52b250fe74d5140bb37 100644 (file)
@@ -5,6 +5,7 @@
 
 struct test_entry
 {
+       int padding; /* hashmap entry no longer needs to be the first member */
        struct hashmap_entry ent;
        /* key and value as two \0-terminated strings */
        char key[FLEX_ARRAY];
@@ -109,7 +110,7 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
                                hashmap_add(&map, &entries[i]->ent);
                        }
 
-                       hashmap_free(&map, 0);
+                       hashmap_free(&map);
                }
        } else {
                /* test map lookups */
@@ -129,7 +130,7 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
                        }
                }
 
-               hashmap_free(&map, 0);
+               hashmap_free(&map);
        }
 }
 
@@ -189,9 +190,7 @@ int cmd__hashmap(int argc, const char **argv)
                        entry = alloc_test_entry(hash, p1, p2);
 
                        /* add / replace entry */
-                       entry = hashmap_put_entry(&map, entry,
-                                               struct test_entry,
-                                               ent /* member name */);
+                       entry = hashmap_put_entry(&map, entry, ent);
 
                        /* print and free replaced entry, if any */
                        puts(entry ? get_value(entry) : "NULL");
@@ -205,10 +204,8 @@ int cmd__hashmap(int argc, const char **argv)
                        /* print result */
                        if (!entry)
                                puts("NULL");
-                       hashmap_for_each_entry_from(&map, entry,
-                                               struct test_entry, ent) {
+                       hashmap_for_each_entry_from(&map, entry, ent)
                                puts(get_value(entry));
-                       }
 
                } else if (!strcmp("remove", cmd) && p1) {
 
@@ -230,7 +227,6 @@ int cmd__hashmap(int argc, const char **argv)
                        struct hashmap_iter iter;
 
                        hashmap_for_each_entry(&map, &iter, entry,
-                                               struct test_entry,
                                                ent /* member name */)
                                printf("%s %s\n", entry->key, get_value(entry));
 
@@ -266,6 +262,6 @@ int cmd__hashmap(int argc, const char **argv)
        }
 
        strbuf_release(&line);
-       hashmap_free(&map, 1);
+       hashmap_free_entries(&map, struct test_entry, ent);
        return 0;
 }