From 87571c3f71ba41d89eef5202f8589daa26f984ca Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 6 Oct 2019 23:30:38 +0000 Subject: hashmap: use *_entry APIs for iteration Inspired by list_for_each_entry in the Linux kernel. Once again, these are somewhat compromised usability-wise by compilers lacking __typeof__ support. Signed-off-by: Eric Wong Reviewed-by: Derrick Stolee Signed-off-by: Junio C Hamano --- attr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'attr.c') diff --git a/attr.c b/attr.c index 6053481610..ca8be46e8e 100644 --- a/attr.c +++ b/attr.c @@ -163,12 +163,13 @@ static void all_attrs_init(struct attr_hashmap *map, struct attr_check *check) if (size != check->all_attrs_nr) { struct attr_hash_entry *e; struct hashmap_iter iter; - hashmap_iter_init(&map->map, &iter); REALLOC_ARRAY(check->all_attrs, size); check->all_attrs_nr = size; - while ((e = hashmap_iter_next(&iter))) { + hashmap_for_each_entry(&map->map, &iter, e, + struct attr_hash_entry, + ent /* member name */) { const struct git_attr *a = e->value; check->all_attrs[a->attr_nr].attr = a; } -- cgit v1.2.3