projects
/
tinc
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6062df4
)
Add an explicit hash_delete() function.
author
Guus Sliepen
<guus@tinc-vpn.org>
Sun, 7 Dec 2014 21:10:16 +0000
(22:10 +0100)
committer
Guus Sliepen
<guus@tinc-vpn.org>
Sun, 7 Dec 2014 21:10:16 +0000
(22:10 +0100)
src/hash.c
patch
|
blob
|
history
src/hash.h
patch
|
blob
|
history
diff --git
a/src/hash.c
b/src/hash.c
index
8fb9ca6
..
91fc3d6
100644
(file)
--- 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;
}
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) {
/* Utility functions */
void hash_clear(hash_t *hash) {
diff --git
a/src/hash.h
b/src/hash.h
index
83ed6af
..
30a15fb
100644
(file)
--- 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_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);
extern void *hash_search(const hash_t *, const void *key);
extern void *hash_search_or_insert(hash_t *, const void *key, const void *value);