Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
pkghash: add pkghash_delete
Baptiste Daroussin committed 4 years ago
commit 78a8abfa1d364e7ff265c1c642830d1b8096ea10
parent 1b7151a
2 files changed +13 -0
modified libpkg/pkghash.c
@@ -218,3 +218,15 @@ pkghash_del(pkghash *h, const char *key)
	h->count--;
	return (true);
}
+

+
void *
+
pkghash_delete(pkghash *h, const char *key)
+
{
+
	pkghash_entry *e = pkghash_get(h, key);
+
	if (e == NULL)
+
		return (NULL);
+
	free(e->key);
+
	e->key = NULL;
+
	h->count--;
+
	return (e->value);
+
}
modified libpkg/pkghash.h
@@ -38,6 +38,7 @@ bool pkghash_next(pkghash_it *it);
void pkghash_loopinit(pkghash *h);
pkghash_entry *pkghash_inext(pkghash *h);
bool pkghash_del(pkghash *h, const char *key);
+
void *pkghash_delete(pkghash *h, const char *key);

#endif