diff options
author | Alex Auvolat <alex.auvolat@ens.fr> | 2015-02-14 12:29:22 +0100 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ens.fr> | 2015-02-14 12:29:22 +0100 |
commit | ba53137f1b687b1c9cbd66fbe306ed1bf6d0cccb (patch) | |
tree | 55cebfa7f54b14601eccbd1bf1f50e33ceee5d76 /src/common/include | |
parent | 630c28c3fd3297c7a0ea7ec7ad4417f521fdaa7f (diff) | |
download | kogata-ba53137f1b687b1c9cbd66fbe306ed1bf6d0cccb.tar.gz kogata-ba53137f1b687b1c9cbd66fbe306ed1bf6d0cccb.zip |
Change hashtbl memory freeing method
Diffstat (limited to 'src/common/include')
-rw-r--r-- | src/common/include/hashtbl.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/common/include/hashtbl.h b/src/common/include/hashtbl.h index ecac0a8..46f2978 100644 --- a/src/common/include/hashtbl.h +++ b/src/common/include/hashtbl.h @@ -19,19 +19,24 @@ typedef struct hashtbl hashtbl_t; typedef size_t hash_t; typedef hash_t (*hash_fun_t)(const void*); typedef bool (*key_eq_fun_t)(const void*, const void*); -typedef void (*free_fun_t)(void*); +typedef void (*kv_iter_fun_t)(void* key, void* value); -hashtbl_t* create_hashtbl(key_eq_fun_t ef, hash_fun_t hf, free_fun_t key_ff, size_t initial_size); // 0 -> default size -void delete_hashtbl(hashtbl_t* ht, free_fun_t data_free_fun); +hashtbl_t* create_hashtbl(key_eq_fun_t ef, hash_fun_t hf, kv_iter_fun_t on_release); // 0 -> default size +void delete_hashtbl(hashtbl_t* ht); bool hashtbl_add(hashtbl_t* ht, void* key, void* v); // true = ok, false on error (OOM for instance) void* hashtbl_find(hashtbl_t* ht, const void* key); // null when not found void hashtbl_remove(hashtbl_t* ht, const void* key); size_t hashtbl_count(hashtbl_t* ht); +void hashtbl_iter(hashtbl_t* ht, kv_iter_fun_t f); hash_t id_hash_fun(const void* v); hash_t str_hash_fun(const void* v); bool id_key_eq_fun(const void* a, const void* b); bool str_key_eq_fun(const void* a, const void* b); +void free_key(void* key, void* val); +void free_val(void* key, void* val); +void free_key_val(void* key, void* val); + /* vim: set ts=4 sw=4 tw=0 noet :*/ |