Skip to content

Commit d470b7a

Browse files
committed
Merge branch 'bw/oidmap-autoinit'
Code clean-up. * bw/oidmap-autoinit: oidmap: ensure map is initialized
2 parents 5550449 + e2a5a02 commit d470b7a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

oidmap.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,30 @@ void oidmap_free(struct oidmap *map, int free_entries)
3333

3434
void *oidmap_get(const struct oidmap *map, const struct object_id *key)
3535
{
36+
if (!map->map.cmpfn)
37+
return NULL;
38+
3639
return hashmap_get_from_hash(&map->map, hash(key), key);
3740
}
3841

3942
void *oidmap_remove(struct oidmap *map, const struct object_id *key)
4043
{
4144
struct hashmap_entry entry;
45+
46+
if (!map->map.cmpfn)
47+
oidmap_init(map, 0);
48+
4249
hashmap_entry_init(&entry, hash(key));
4350
return hashmap_remove(&map->map, &entry, key);
4451
}
4552

4653
void *oidmap_put(struct oidmap *map, void *entry)
4754
{
4855
struct oidmap_entry *to_put = entry;
56+
57+
if (!map->map.cmpfn)
58+
oidmap_init(map, 0);
59+
4960
hashmap_entry_init(&to_put->internal_entry, hash(&to_put->oid));
5061
return hashmap_put(&map->map, to_put);
5162
}

0 commit comments

Comments
 (0)