]> git.ipfire.org Git - thirdparty/git.git/blobdiff - ref-filter.c
OFFSETOF_VAR macro to simplify hashmap iterators
[thirdparty/git.git] / ref-filter.c
index 9999426914773af314a0c6c72016a3313ee91ee2..0950b789e3990d84da998fe5e6b115f5845ac7a9 100644 (file)
@@ -84,12 +84,15 @@ struct ref_to_worktree_entry {
 };
 
 static int ref_to_worktree_map_cmpfnc(const void *unused_lookupdata,
-                                     const void *existing_hashmap_entry_to_test,
-                                     const void *key,
+                                     const struct hashmap_entry *eptr,
+                                     const struct hashmap_entry *kptr,
                                      const void *keydata_aka_refname)
 {
-       const struct ref_to_worktree_entry *e = existing_hashmap_entry_to_test;
-       const struct ref_to_worktree_entry *k = key;
+       const struct ref_to_worktree_entry *e, *k;
+
+       e = container_of(eptr, const struct ref_to_worktree_entry, ent);
+       k = container_of(kptr, const struct ref_to_worktree_entry, ent);
+
        return strcmp(e->wt->head_ref,
                keydata_aka_refname ? keydata_aka_refname : k->wt->head_ref);
 }
@@ -2169,7 +2172,8 @@ void ref_array_clear(struct ref_array *array)
        used_atom_cnt = 0;
 
        if (ref_to_worktree_map.worktrees) {
-               hashmap_free(&(ref_to_worktree_map.map), 1);
+               hashmap_free_entries(&(ref_to_worktree_map.map),
+                                       struct ref_to_worktree_entry, ent);
                free_worktrees(ref_to_worktree_map.worktrees);
                ref_to_worktree_map.worktrees = NULL;
        }