From: Guus Sliepen Date: Sun, 7 Dec 2014 21:10:16 +0000 (+0100) Subject: Add an explicit hash_delete() function. X-Git-Tag: release-1.1pre11~25 X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=9d48d5b7d48ad23e23eae02feae69bdc5ae80c8e;p=tinc Add an explicit hash_delete() function. --- diff --git a/src/hash.c b/src/hash.c index 8fb9ca69..91fc3d67 100644 --- a/src/hash.c +++ b/src/hash.c @@ -91,6 +91,13 @@ void *hash_search_or_insert(hash_t *hash, const void *key, const void *value) { return NULL; } +/* Deleting */ + +void hash_delete(hash_t *hash, const void *key) { + uint32_t i = modulo(hash_function(key, hash->size), hash->n); + hash->values[i] = NULL; +} + /* Utility functions */ void hash_clear(hash_t *hash) { diff --git a/src/hash.h b/src/hash.h index 83ed6aff..30a15fb2 100644 --- a/src/hash.h +++ b/src/hash.h @@ -31,6 +31,7 @@ extern hash_t *hash_alloc(size_t n, size_t size) __attribute__ ((__malloc__)); extern void hash_free(hash_t *); extern void hash_insert(hash_t *, const void *key, const void *value); +extern void hash_delete(hash_t *, const void *key); extern void *hash_search(const hash_t *, const void *key); extern void *hash_search_or_insert(hash_t *, const void *key, const void *value);