hashmap: introduce hashmap_free_entries
`hashmap_free_entries' behaves like `container_of' and passes the offset of the hashmap_entry struct to the internal `hashmap_free_' function, allowing the function to free any struct pointer regardless of where the hashmap_entry field is located. `hashmap_free' no longer takes any arguments aside from the hashmap itself. Signed-off-by: Eric Wong <e@80x24.org> Reviewed-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
8a973d0bb3
commit
c8e424c9c9
@ -366,7 +366,7 @@ static void find_non_local_tags(const struct ref *refs,
|
||||
item = refname_hash_add(&remote_refs, ref->name, &ref->old_oid);
|
||||
string_list_insert(&remote_refs_list, ref->name);
|
||||
}
|
||||
hashmap_free(&existing_refs, 1);
|
||||
hashmap_free_entries(&existing_refs, struct refname_hash_entry, ent);
|
||||
|
||||
/*
|
||||
* We may have a final lightweight tag that needs to be
|
||||
@ -401,7 +401,7 @@ static void find_non_local_tags(const struct ref *refs,
|
||||
**tail = rm;
|
||||
*tail = &rm->next;
|
||||
}
|
||||
hashmap_free(&remote_refs, 1);
|
||||
hashmap_free_entries(&remote_refs, struct refname_hash_entry, ent);
|
||||
string_list_clear(&remote_refs_list, 0);
|
||||
}
|
||||
|
||||
@ -530,7 +530,7 @@ static struct ref *get_ref_map(struct remote *remote,
|
||||
}
|
||||
}
|
||||
}
|
||||
hashmap_free(&existing_refs, 1);
|
||||
hashmap_free_entries(&existing_refs, struct refname_hash_entry, ent);
|
||||
|
||||
return ref_map;
|
||||
}
|
||||
|
Reference in New Issue
Block a user