5 struct hashmap_entry hash;
9 static int oidset_hashcmp(const void *unused_cmp_data,
10 const void *va, const void *vb,
13 const struct oidset_entry *a = va, *b = vb;
14 const struct object_id *key = vkey;
15 return oidcmp(&a->oid, key ? key : &b->oid);
18 int oidset_contains(const struct oidset *set, const struct object_id *oid)
20 struct hashmap_entry key;
25 hashmap_entry_init(&key, sha1hash(oid->hash));
26 return !!hashmap_get(&set->map, &key, oid);
29 int oidset_insert(struct oidset *set, const struct object_id *oid)
31 struct oidset_entry *entry;
34 hashmap_init(&set->map, oidset_hashcmp, NULL, 0);
36 if (oidset_contains(set, oid))
39 entry = xmalloc(sizeof(*entry));
40 hashmap_entry_init(&entry->hash, sha1hash(oid->hash));
41 oidcpy(&entry->oid, oid);
43 hashmap_add(&set->map, entry);
47 void oidset_clear(struct oidset *set)
49 hashmap_free(&set->map, 1);