From e8e507b38b8c4429abd6e7b32fe8e3029bfab065 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 10 Apr 2011 00:55:32 +0200 Subject: xps: Use specific font cache struct instead of hash table. --- xps/xps_zip.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) (limited to 'xps/xps_zip.c') diff --git a/xps/xps_zip.c b/xps/xps_zip.c index 57769b59..a0c981bf 100644 --- a/xps/xps_zip.c +++ b/xps/xps_zip.c @@ -398,9 +398,6 @@ xps_open_directory(xps_context **ctxp, char *directory) ctx = fz_malloc(sizeof(xps_context)); memset(ctx, 0, sizeof(xps_context)); - ctx->font_table = xps_hash_new(); - ctx->colorspace_table = xps_hash_new(); - ctx->start_part = NULL; ctx->directory = fz_strdup(directory); @@ -423,9 +420,6 @@ xps_open_stream(xps_context **ctxp, fz_stream *file) ctx = fz_malloc(sizeof(xps_context)); memset(ctx, 0, sizeof(xps_context)); - ctx->font_table = xps_hash_new(); - ctx->colorspace_table = xps_hash_new(); - ctx->start_part = NULL; ctx->file = fz_keep_stream(file); @@ -476,24 +470,10 @@ xps_open_file(xps_context **ctxp, char *filename) return fz_okay; } -static void xps_free_key_func(void *ptr) -{ - fz_free(ptr); -} - -static void xps_free_font_func(void *ptr) -{ - fz_drop_font(ptr); -} - -static void xps_free_colorspace_func(void *ptr) -{ - fz_drop_colorspace(ptr); -} - void xps_free_context(xps_context *ctx) { + xps_font_cache *font, *next; int i; if (ctx->file) @@ -503,8 +483,16 @@ xps_free_context(xps_context *ctx) fz_free(ctx->zip_table[i].name); fz_free(ctx->zip_table); - xps_hash_free(ctx->font_table, xps_free_key_func, xps_free_font_func); - xps_hash_free(ctx->colorspace_table, xps_free_key_func, xps_free_colorspace_func); + font = ctx->font_table; + while (font) + { + next = font->next; + fz_drop_font(font->font); + fz_free(font->name); + fz_free(font); + font = next; + } + xps_free_page_list(ctx); fz_free(ctx->start_part); -- cgit v1.2.3