hashmap_add takes "struct hashmap_entry *"

This is less error-prone than "void *" as the compiler now
detects invalid types being passed.

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:
Eric Wong
2019-10-06 23:30:29 +00:00
committed by Junio C Hamano
parent f6eb6bdcf2
commit b94e5c1df6
20 changed files with 31 additions and 31 deletions

View File

@ -201,12 +201,12 @@ void *hashmap_get_next(const struct hashmap *map,
return NULL;
}
void hashmap_add(struct hashmap *map, void *entry)
void hashmap_add(struct hashmap *map, struct hashmap_entry *entry)
{
unsigned int b = bucket(map, entry);
/* add entry */
((struct hashmap_entry *) entry)->next = map->table[b];
entry->next = map->table[b];
map->table[b] = entry;
/* fix size and rehash if appropriate */
@ -302,7 +302,7 @@ const void *memintern(const void *data, size_t len)
FLEX_ALLOC_MEM(e, data, data, len);
hashmap_entry_init(&e->ent, key.ent.hash);
e->len = len;
hashmap_add(&map, e);
hashmap_add(&map, &e->ent);
}
return e->data;
}