diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2020-02-23 16:23:11 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2020-02-23 20:59:39 +0000 |
commit | 61187d31ab7ba292510e1e56886325a1c6a1c822 (patch) | |
tree | a7475772f112f56a6f2cfbe2ee9cec38f053dae1 /utils | |
parent | be659af7e563527270a8725ae42ecf7c25aecc7e (diff) | |
download | netsurf-61187d31ab7ba292510e1e56886325a1c6a1c822.tar.gz netsurf-61187d31ab7ba292510e1e56886325a1c6a1c822.tar.bz2 |
utils: Add hashmap parameter function types
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'utils')
-rw-r--r-- | utils/hashmap.h | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/utils/hashmap.h b/utils/hashmap.h index 4e1237ae9..462b51ed2 100644 --- a/utils/hashmap.h +++ b/utils/hashmap.h @@ -32,6 +32,36 @@ typedef struct hashmap_s hashmap_t; /** + * Key cloning function type + */ +typedef void* (*hashmap_key_clone_t)(void *); + +/** + * Key destructor function type + */ +typedef void (*hashmap_key_destroy_t)(void *); + +/** + * Key hashing function type + */ +typedef uint32_t (*hashmap_key_hash_t)(void *); + +/** + * Key comparison function type + */ +typedef bool (*hashmap_key_eq_t)(void *, void*); + +/** + * Value allocation function type + */ +typedef void* (*hashmap_value_alloc_t)(void *); + +/** + * Value destructor function type + */ +typedef void (*hashmap_value_destroy_t)(void *); + +/** * Parameters for hashmaps */ typedef struct { @@ -39,12 +69,12 @@ typedef struct { * A function which when called will clone a key and give * ownership of the returned object to the hashmap */ - void * (*key_clone)(void *key); + hashmap_key_clone_t key_clone; /** * A function which when given a key will return its hash. */ - uint32_t (*key_hash)(void *key); + hashmap_key_hash_t key_hash; /** * A function to compare two keys and return if they are equal. @@ -52,22 +82,22 @@ typedef struct { * as the function is a full equality model. * (i.e. key1 == key2 => key2 == key1) */ - bool (*key_eq)(void *key1, void *key2); + hashmap_key_eq_t key_eq; /** * A function which when called will destroy a key object */ - void (*key_destroy)(void *key); + hashmap_key_destroy_t key_destroy; /** * A function which when called will allocate a value object */ - void * (*value_alloc)(void *key); + hashmap_value_alloc_t value_alloc; /** * A function which when called will destroy a value object */ - void (*value_destroy)(void *value); + hashmap_value_destroy_t value_destroy; } hashmap_parameters_t; |