summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-12-28 14:57:11 +0100
committerTor Andersson <tor.andersson@artifex.com>2017-01-17 17:15:59 +0100
commit9322cd236f2c74461ab5d20e0a399035051628ae (patch)
treec621f06eed60f5eb473afe315eb630cbca712825 /include
parent2d8d711df455bf5cc5a7c7ba08c98867df3f33ef (diff)
downloadmupdf-9322cd236f2c74461ab5d20e0a399035051628ae.tar.xz
Add value destructor callback to fz_hash_table.
This allows us to prune the iteration functions. We also remove a few other unused functions.
Diffstat (limited to 'include')
-rw-r--r--include/mupdf/fitz/hash.h20
1 files changed, 11 insertions, 9 deletions
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);