diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-12-28 14:57:11 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2017-01-17 17:15:59 +0100 |
commit | 9322cd236f2c74461ab5d20e0a399035051628ae (patch) | |
tree | c621f06eed60f5eb473afe315eb630cbca712825 /source/pdf/pdf-resources.c | |
parent | 2d8d711df455bf5cc5a7c7ba08c98867df3f33ef (diff) | |
download | mupdf-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 'source/pdf/pdf-resources.c')
-rw-r--r-- | source/pdf/pdf-resources.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/source/pdf/pdf-resources.c b/source/pdf/pdf-resources.c index ad195393..002906f8 100644 --- a/source/pdf/pdf-resources.c +++ b/source/pdf/pdf-resources.c @@ -76,7 +76,7 @@ pdf_find_image_resource(fz_context *ctx, pdf_document *doc, fz_image *item, unsi if (!doc->resources.images) { - doc->resources.images = fz_new_hash_table(ctx, 4096, 16, -1); + doc->resources.images = fz_new_hash_table(ctx, 4096, 16, -1, (fz_hash_table_drop_fn)pdf_drop_obj); pdf_preload_image_resources(ctx, doc); } @@ -110,7 +110,7 @@ pdf_find_font_resource(fz_context *ctx, pdf_document *doc, fz_buffer *item, unsi pdf_obj *res; if (!doc->resources.fonts) - doc->resources.fonts = fz_new_hash_table(ctx, 4096, 16, -1); + doc->resources.fonts = fz_new_hash_table(ctx, 4096, 16, -1, (fz_hash_table_drop_fn)pdf_drop_obj); /* Create md5 and see if we have the item in our table */ fz_md5_buffer(ctx, item, digest); @@ -131,25 +131,12 @@ pdf_insert_font_resource(fz_context *ctx, pdf_document *doc, unsigned char diges return res; } -static void -res_table_free(fz_context *ctx, fz_hash_table *hash) -{ - int i, n; - if (hash) - { - n = fz_hash_len(ctx, hash); - for (i = 0; i < n; i++) - pdf_drop_obj(ctx, fz_hash_get_val(ctx, hash, i)); - fz_drop_hash(ctx, hash); - } -} - void pdf_drop_resource_tables(fz_context *ctx, pdf_document *doc) { if (doc) { - res_table_free(ctx, doc->resources.fonts); - res_table_free(ctx, doc->resources.images); + fz_drop_hash_table(ctx, doc->resources.fonts); + fz_drop_hash_table(ctx, doc->resources.images); } } |