refs: convert delete_ref and refs_delete_ref to struct object_id
[alt-git.git] / oidset.c
blobf1f874aaad2c0375eb80d3b714ae6ad460c75ddc
1 #include "cache.h"
2 #include "oidset.h"
4 int oidset_contains(const struct oidset *set, const struct object_id *oid)
6 if (!set->map.map.tablesize)
7 return 0;
8 return !!oidmap_get(&set->map, oid);
11 int oidset_insert(struct oidset *set, const struct object_id *oid)
13 struct oidmap_entry *entry;
15 if (!set->map.map.tablesize)
16 oidmap_init(&set->map, 0);
17 else if (oidset_contains(set, oid))
18 return 1;
20 entry = xmalloc(sizeof(*entry));
21 oidcpy(&entry->oid, oid);
23 oidmap_put(&set->map, entry);
24 return 0;
27 void oidset_clear(struct oidset *set)
29 oidmap_free(&set->map, 1);