1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-31 14:27:54 +01:00
git/oidset.c

31 lines
585 B
C
Raw Normal View History

#include "cache.h"
#include "oidset.h"
int oidset_contains(const struct oidset *set, const struct object_id *oid)
{
if (!set->map.map.tablesize)
return 0;
return !!oidmap_get(&set->map, oid);
}
int oidset_insert(struct oidset *set, const struct object_id *oid)
{
struct oidmap_entry *entry;
if (!set->map.map.tablesize)
oidmap_init(&set->map, 0);
else if (oidset_contains(set, oid))
return 1;
entry = xmalloc(sizeof(*entry));
oidcpy(&entry->oid, oid);
oidmap_put(&set->map, entry);
return 0;
}
void oidset_clear(struct oidset *set)
{
oidmap_free(&set->map, 1);
}