Staging
v0.5.1
https://github.com/git/git
Revision 7cdafcaacf677b9e0700fa988c247bda192db48d authored by Johannes Schindelin on 04 December 2019, 20:33:29 UTC, committed by Johannes Schindelin on 06 December 2019, 15:26:58 UTC
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent e904deb
Raw File
Tip revision: 7cdafcaacf677b9e0700fa988c247bda192db48d authored by Johannes Schindelin on 04 December 2019, 20:33:29 UTC
Git 2.15.4
Tip revision: 7cdafca
oidset.c
#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);
}
back to top