hashmap_entry_init takes "struct hashmap_entry *"

C compilers do type checking to make life easier for us.  So
rely on that and update all hashmap_entry_init callers to take
"struct hashmap_entry *" to avoid future bugs while improving
safety and readability.

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:27 +00:00
committed by Junio C Hamano
parent d0a48a0a1d
commit d22245a2e3
23 changed files with 55 additions and 52 deletions

View File

@ -61,7 +61,7 @@ static struct dir_rename_entry *dir_rename_find_entry(struct hashmap *hashmap,
if (dir == NULL)
return NULL;
hashmap_entry_init(&key, strhash(dir));
hashmap_entry_init(&key.ent, strhash(dir));
key.dir = dir;
return hashmap_get(hashmap, &key, NULL);
}
@ -85,7 +85,7 @@ static void dir_rename_init(struct hashmap *map)
static void dir_rename_entry_init(struct dir_rename_entry *entry,
char *directory)
{
hashmap_entry_init(entry, strhash(directory));
hashmap_entry_init(&entry->ent, strhash(directory));
entry->dir = directory;
entry->non_unique_new_dir = 0;
strbuf_init(&entry->new_dir, 0);
@ -97,7 +97,7 @@ static struct collision_entry *collision_find_entry(struct hashmap *hashmap,
{
struct collision_entry key;
hashmap_entry_init(&key, strhash(target_file));
hashmap_entry_init(&key.ent, strhash(target_file));
key.target_file = target_file;
return hashmap_get(hashmap, &key, NULL);
}
@ -454,7 +454,7 @@ static int save_files_dirs(const struct object_id *oid,
strbuf_addstr(base, path);
FLEX_ALLOC_MEM(entry, path, base->buf, base->len);
hashmap_entry_init(entry, path_hash(entry->path));
hashmap_entry_init(&entry->e, path_hash(entry->path));
hashmap_add(&opt->current_file_dir_set, entry);
strbuf_setlen(base, baselen);
@ -731,7 +731,7 @@ static char *unique_path(struct merge_options *opt, const char *path, const char
}
FLEX_ALLOC_MEM(entry, path, newpath.buf, newpath.len);
hashmap_entry_init(entry, path_hash(entry->path));
hashmap_entry_init(&entry->e, path_hash(entry->path));
hashmap_add(&opt->current_file_dir_set, entry);
return strbuf_detach(&newpath, NULL);
}
@ -2358,7 +2358,8 @@ static void compute_collisions(struct hashmap *collisions,
if (!collision_ent) {
collision_ent = xcalloc(1,
sizeof(struct collision_entry));
hashmap_entry_init(collision_ent, strhash(new_path));
hashmap_entry_init(&collision_ent->ent,
strhash(new_path));
hashmap_put(collisions, collision_ent);
collision_ent->target_file = new_path;
} else {