5 struct hashmap_entry hash
;
9 static int oidset_hashcmp(const void *va
, const void *vb
,
12 const struct oidset_entry
*a
= va
, *b
= vb
;
13 const struct object_id
*key
= vkey
;
14 return oidcmp(&a
->oid
, key
? key
: &b
->oid
);
17 int oidset_contains(const struct oidset
*set
, const struct object_id
*oid
)
19 struct hashmap_entry key
;
24 hashmap_entry_init(&key
, sha1hash(oid
->hash
));
25 return !!hashmap_get(&set
->map
, &key
, oid
);
28 int oidset_insert(struct oidset
*set
, const struct object_id
*oid
)
30 struct oidset_entry
*entry
;
33 hashmap_init(&set
->map
, oidset_hashcmp
, 0);
35 if (oidset_contains(set
, oid
))
38 entry
= xmalloc(sizeof(*entry
));
39 hashmap_entry_init(&entry
->hash
, sha1hash(oid
->hash
));
40 oidcpy(&entry
->oid
, oid
);
42 hashmap_add(&set
->map
, entry
);
46 void oidset_clear(struct oidset
*set
)
48 hashmap_free(&set
->map
, 1);