From 9322cd236f2c74461ab5d20e0a399035051628ae Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 28 Dec 2016 14:57:11 +0100 Subject: Add value destructor callback to fz_hash_table. This allows us to prune the iteration functions. We also remove a few other unused functions. --- include/mupdf/fitz/hash.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/mupdf/fitz/hash.h b/include/mupdf/fitz/hash.h index 4b1d7a05..89a56bc3 100644 --- a/include/mupdf/fitz/hash.h +++ b/include/mupdf/fitz/hash.h @@ -7,23 +7,25 @@ /* * Generic hash-table with fixed-length keys. + * + * The keys and values are NOT reference counted by the hash table. + * Callers are responsible for taking care the reference counts are correct. + * Inserting a duplicate entry will NOT overwrite the old value, and will + * return the old value. + * + * The drop_val callback function is only used to release values when the hash table + * is destroyed. */ typedef struct fz_hash_table_s fz_hash_table; +typedef void (*fz_hash_table_drop_fn)(fz_context *ctx, void *val); -fz_hash_table *fz_new_hash_table(fz_context *ctx, int initialsize, int keylen, int lock); -void fz_empty_hash(fz_context *ctx, fz_hash_table *table); -void fz_drop_hash(fz_context *ctx, fz_hash_table *table); +fz_hash_table *fz_new_hash_table(fz_context *ctx, int initialsize, int keylen, int lock, fz_hash_table_drop_fn drop_val); +void fz_drop_hash_table(fz_context *ctx, fz_hash_table *table); void *fz_hash_find(fz_context *ctx, fz_hash_table *table, const void *key); void *fz_hash_insert(fz_context *ctx, fz_hash_table *table, const void *key, void *val); -void *fz_hash_insert_with_pos(fz_context *ctx, fz_hash_table *table, const void *key, void *val, unsigned *pos); void fz_hash_remove(fz_context *ctx, fz_hash_table *table, const void *key); -void fz_hash_remove_fast(fz_context *ctx, fz_hash_table *table, const void *key, unsigned pos); - -int fz_hash_len(fz_context *ctx, fz_hash_table *table); -void *fz_hash_get_key(fz_context *ctx, fz_hash_table *table, int idx); -void *fz_hash_get_val(fz_context *ctx, fz_hash_table *table, int idx); void fz_print_hash(fz_context *ctx, fz_output *out, fz_hash_table *table); void fz_print_hash_details(fz_context *ctx, fz_output *out, fz_hash_table *table, void (*details)(fz_context*, fz_output*, void*), int compact); -- cgit v1.2.3