diff options
Diffstat (limited to 'src/shared/hashmap.h')
-rw-r--r-- | src/shared/hashmap.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/shared/hashmap.h b/src/shared/hashmap.h index b739262ab3..53b04eb033 100644 --- a/src/shared/hashmap.h +++ b/src/shared/hashmap.h @@ -41,27 +41,34 @@ typedef _IteratorStruct* Iterator; typedef unsigned long (*hash_func_t)(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]); typedef int (*compare_func_t)(const void *a, const void *b); +struct hash_ops { + hash_func_t hash; + compare_func_t compare; +}; + unsigned long string_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) _pure_; int string_compare_func(const void *a, const void *b) _pure_; +extern const struct hash_ops string_hash_ops; /* This will compare the passed pointers directly, and will not * dereference them. This is hence not useful for strings or * suchlike. */ unsigned long trivial_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) _pure_; int trivial_compare_func(const void *a, const void *b) _const_; +extern const struct hash_ops trivial_hash_ops; -Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func); +Hashmap *hashmap_new(const struct hash_ops *hash_ops); void hashmap_free(Hashmap *h); void hashmap_free_free(Hashmap *h); int hashmap_put(Hashmap *h, const void *key, void *value); void *hashmap_get(Hashmap *h, const void *key); +void *hashmap_get2(Hashmap *h, const void *key, void **rkey); bool hashmap_contains(Hashmap *h, const void *key); unsigned hashmap_size(Hashmap *h) _pure_; void *hashmap_iterate(Hashmap *h, Iterator *i, const void **key); -void *hashmap_iterate_backwards(Hashmap *h, Iterator *i, const void **key); void hashmap_clear(Hashmap *h); void hashmap_clear_free(Hashmap *h); |