diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 17:03:56 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 17:03:56 +0000 |
commit | 18da3ffcd7f3c8a0c5f790c801b5813503c2273d (patch) | |
tree | 84caf98dc5cef3d123c56ba12e35fd67026e0693 /shared/hash.h | |
parent | Initial commit. (diff) | |
download | kmod-18da3ffcd7f3c8a0c5f790c801b5813503c2273d.tar.xz kmod-18da3ffcd7f3c8a0c5f790c801b5813503c2273d.zip |
Adding upstream version 31+20240202.upstream/31+20240202
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'shared/hash.h')
-rw-r--r-- | shared/hash.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/shared/hash.h b/shared/hash.h new file mode 100644 index 0000000..ca0af05 --- /dev/null +++ b/shared/hash.h @@ -0,0 +1,22 @@ +#pragma once + +#include <stdbool.h> + +struct hash; + +struct hash_iter { + const struct hash *hash; + unsigned int bucket; + unsigned int entry; +}; + +struct hash *hash_new(unsigned int n_buckets, void (*free_value)(void *value)); +void hash_free(struct hash *hash); +int hash_add(struct hash *hash, const char *key, const void *value); +int hash_add_unique(struct hash *hash, const char *key, const void *value); +int hash_del(struct hash *hash, const char *key); +void *hash_find(const struct hash *hash, const char *key); +unsigned int hash_get_count(const struct hash *hash); +void hash_iter_init(const struct hash *hash, struct hash_iter *iter); +bool hash_iter_next(struct hash_iter *iter, const char **key, + const void **value); |