2017-02-08 23:53:07 +03:00
|
|
|
#include "cache.h"
|
|
|
|
#include "oidset.h"
|
|
|
|
|
|
|
|
int oidset_contains(const struct oidset *set, const struct object_id *oid)
|
|
|
|
{
|
2017-09-30 01:54:22 +03:00
|
|
|
if (!set->map.map.tablesize)
|
2017-02-08 23:53:07 +03:00
|
|
|
return 0;
|
2017-09-30 01:54:22 +03:00
|
|
|
return !!oidmap_get(&set->map, oid);
|
2017-02-08 23:53:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int oidset_insert(struct oidset *set, const struct object_id *oid)
|
|
|
|
{
|
2017-09-30 01:54:22 +03:00
|
|
|
struct oidmap_entry *entry;
|
2017-02-08 23:53:07 +03:00
|
|
|
|
2017-09-30 01:54:22 +03:00
|
|
|
if (!set->map.map.tablesize)
|
|
|
|
oidmap_init(&set->map, 0);
|
|
|
|
else if (oidset_contains(set, oid))
|
2017-02-08 23:53:07 +03:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
entry = xmalloc(sizeof(*entry));
|
|
|
|
oidcpy(&entry->oid, oid);
|
|
|
|
|
2017-09-30 01:54:22 +03:00
|
|
|
oidmap_put(&set->map, entry);
|
2017-02-08 23:53:07 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void oidset_clear(struct oidset *set)
|
|
|
|
{
|
2017-09-30 01:54:22 +03:00
|
|
|
oidmap_free(&set->map, 1);
|
2017-02-08 23:53:07 +03:00
|
|
|
}
|