From 6af0abc477539365a19a4797babfd567da4d375f Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 3 Apr 2011 15:26:44 +0200 Subject: xps: Remove xps_context from hash table implementation. --- xps/muxps.h | 10 +++++----- xps/xps_glyphs.c | 2 +- xps/xps_hash.c | 20 ++++++++++---------- xps/xps_zip.c | 13 ++++++------- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/xps/muxps.h b/xps/muxps.h index 371b5983..f3f2cdf4 100644 --- a/xps/muxps.h +++ b/xps/muxps.h @@ -38,12 +38,12 @@ void xps_absolute_path(char *output, char *base_uri, char *path, int output_size typedef struct xps_hash_table_s xps_hash_table; -xps_hash_table *xps_hash_new(xps_context *ctx); +xps_hash_table *xps_hash_new(void); void *xps_hash_lookup(xps_hash_table *table, char *key); -int xps_hash_insert(xps_context *ctx, xps_hash_table *table, char *key, void *value); -void xps_hash_free(xps_context *ctx, xps_hash_table *table, - void (*free_key)(xps_context *ctx, void *), - void (*free_value)(xps_context *ctx, void *)); +int xps_hash_insert(xps_hash_table *table, char *key, void *value); +void xps_hash_free(xps_hash_table *table, + void (*free_key)(void *), + void (*free_value)(void *)); void xps_hash_debug(xps_hash_table *table); /* diff --git a/xps/xps_glyphs.c b/xps/xps_glyphs.c index 91c7dbcd..9d0d9fca 100644 --- a/xps/xps_glyphs.c +++ b/xps/xps_glyphs.c @@ -481,7 +481,7 @@ xps_parse_glyphs(xps_context *ctx, fz_matrix ctm, xps_select_best_font_encoding(font); - xps_hash_insert(ctx, ctx->font_table, part->name, font); + xps_hash_insert(ctx->font_table, part->name, font); /* NOTE: we kept part->name in the hashtable and part->data in the font */ fz_free(part); diff --git a/xps/xps_hash.c b/xps/xps_hash.c index 71e97097..f2a7d48a 100644 --- a/xps/xps_hash.c +++ b/xps/xps_hash.c @@ -48,7 +48,7 @@ xps_hash(char *s) } xps_hash_table * -xps_hash_new(xps_context *ctx) +xps_hash_new(void) { xps_hash_table *table; @@ -63,7 +63,7 @@ xps_hash_new(xps_context *ctx) } static int -xps_hash_double(xps_context *ctx, xps_hash_table *table) +xps_hash_double(xps_hash_table *table) { xps_hash_entry *old_entries; xps_hash_entry *new_entries; @@ -91,7 +91,7 @@ xps_hash_double(xps_context *ctx, xps_hash_table *table) for (i = 0; i < old_size; i++) if (old_entries[i].value) - xps_hash_insert(ctx, table, old_entries[i].key, old_entries[i].value); + xps_hash_insert(table, old_entries[i].key, old_entries[i].value); fz_free(old_entries); @@ -99,18 +99,18 @@ xps_hash_double(xps_context *ctx, xps_hash_table *table) } void -xps_hash_free(xps_context *ctx, xps_hash_table *table, - void (*free_key)(xps_context *ctx, void *), - void (*free_value)(xps_context *ctx, void *)) +xps_hash_free(xps_hash_table *table, + void (*free_key)(void *), + void (*free_value)(void *)) { int i; for (i = 0; i < table->size; i++) { if (table->entries[i].key && free_key) - free_key(ctx, table->entries[i].key); + free_key(table->entries[i].key); if (table->entries[i].value && free_value) - free_value(ctx, table->entries[i].value); + free_value(table->entries[i].value); } fz_free(table->entries); @@ -137,7 +137,7 @@ xps_hash_lookup(xps_hash_table *table, char *key) } int -xps_hash_insert(xps_context *ctx, xps_hash_table *table, char *key, void *value) +xps_hash_insert(xps_hash_table *table, char *key, void *value) { xps_hash_entry *entries; unsigned int size, pos; @@ -145,7 +145,7 @@ xps_hash_insert(xps_context *ctx, xps_hash_table *table, char *key, void *value) /* Grow the table at 80% load */ if (table->load > table->size * 8 / 10) { - if (xps_hash_double(ctx, table) < 0) + if (xps_hash_double(table) < 0) return fz_rethrow(-1, "cannot grow hash table"); } diff --git a/xps/xps_zip.c b/xps/xps_zip.c index 89509cb3..d353ec11 100644 --- a/xps/xps_zip.c +++ b/xps/xps_zip.c @@ -433,20 +433,20 @@ xps_new_context(void) memset(ctx, 0, sizeof(xps_context)); - ctx->font_table = xps_hash_new(ctx); - ctx->colorspace_table = xps_hash_new(ctx); + ctx->font_table = xps_hash_new(); + ctx->colorspace_table = xps_hash_new(); ctx->start_part = NULL; return ctx; } -static void xps_free_key_func(xps_context *ctx, void *ptr) +static void xps_free_key_func(void *ptr) { fz_free(ptr); } -static void xps_free_font_func(xps_context *ctx, void *ptr) +static void xps_free_font_func(void *ptr) { fz_dropfont(ptr); } @@ -463,9 +463,8 @@ xps_free_context(xps_context *ctx) fz_free(ctx->zip_table[i].name); fz_free(ctx->zip_table); - /* TODO: free resources too */ - xps_hash_free(ctx, ctx->font_table, xps_free_key_func, xps_free_font_func); - xps_hash_free(ctx, ctx->colorspace_table, xps_free_key_func, NULL); + xps_hash_free(ctx->font_table, xps_free_key_func, xps_free_font_func); + xps_hash_free(ctx->colorspace_table, xps_free_key_func, NULL); xps_free_page_list(ctx); -- cgit v1.2.3