From a22a4994fd5ca4dcf20170f88a5b7fe1a5df49c4 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 24 Mar 2017 16:34:48 -0400 Subject: Ensure fz_store_types are all static const. --- include/mupdf/fitz/store.h | 8 ++++---- source/fitz/draw-device.c | 2 +- source/fitz/image.c | 2 +- source/fitz/store.c | 10 +++++----- source/pdf/pdf-font.c | 8 +++++--- source/pdf/pdf-store.c | 2 +- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/include/mupdf/fitz/store.h b/include/mupdf/fitz/store.h index f081e987..d637b1cc 100644 --- a/include/mupdf/fitz/store.h +++ b/include/mupdf/fitz/store.h @@ -180,7 +180,7 @@ fz_store *fz_keep_store_context(fz_context *ctx); type: Functions used to manipulate the key. */ -void *fz_store_item(fz_context *ctx, void *key, void *val, size_t itemsize, fz_store_type *type); +void *fz_store_item(fz_context *ctx, void *key, void *val, size_t itemsize, const fz_store_type *type); /* fz_find_item: Find an item within the store. @@ -195,7 +195,7 @@ void *fz_store_item(fz_context *ctx, void *key, void *val, size_t itemsize, fz_s Returns NULL for not found, otherwise returns a pointer to the value indexed by key to which a reference has been taken. */ -void *fz_find_item(fz_context *ctx, fz_store_drop_fn *drop, void *key, fz_store_type *type); +void *fz_find_item(fz_context *ctx, fz_store_drop_fn *drop, void *key, const fz_store_type *type); /* fz_remove_item: Remove an item from the store. @@ -209,7 +209,7 @@ void *fz_find_item(fz_context *ctx, fz_store_drop_fn *drop, void *key, fz_store_ type: Functions used to manipulate the key. */ -void fz_remove_item(fz_context *ctx, fz_store_drop_fn *drop, void *key, fz_store_type *type); +void fz_remove_item(fz_context *ctx, fz_store_drop_fn *drop, void *key, const fz_store_type *type); /* fz_empty_store: Evict everything from the store. @@ -243,7 +243,7 @@ int fz_shrink_store(fz_context *ctx, unsigned int percent); typedef int (fz_store_filter_fn)(fz_context *ctx, void *arg, void *key); -void fz_filter_store(fz_context *ctx, fz_store_filter_fn *fn, void *arg, fz_store_type *type); +void fz_filter_store(fz_context *ctx, fz_store_filter_fn *fn, void *arg, const fz_store_type *type); /* fz_print_store: Dump the contents of the store for debugging. diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c index 9d7a19af..857844fe 100644 --- a/source/fitz/draw-device.c +++ b/source/fitz/draw-device.c @@ -1953,7 +1953,7 @@ fz_print_tile(fz_context *ctx, fz_output *out, void *key_) fz_write_printf(ctx, out, "(tile id=%x, ctm=%g %g %g %g) ", key->id, key->ctm[0], key->ctm[1], key->ctm[2], key->ctm[3]); } -static fz_store_type fz_tile_store_type = +static const fz_store_type fz_tile_store_type = { fz_make_hash_tile_key, fz_keep_tile_key, diff --git a/source/fitz/image.c b/source/fitz/image.c index 72855395..3b0a93d6 100644 --- a/source/fitz/image.c +++ b/source/fitz/image.c @@ -96,7 +96,7 @@ fz_needs_reap_image_key(fz_context *ctx, void *key_) return (key->image->key_storable.needs_reaping); } -static fz_store_type fz_image_store_type = +static const fz_store_type fz_image_store_type = { fz_make_hash_image_key, fz_keep_image_key, diff --git a/source/fitz/store.c b/source/fitz/store.c index 70f25029..f7cda31a 100644 --- a/source/fitz/store.c +++ b/source/fitz/store.c @@ -10,7 +10,7 @@ struct fz_item_s fz_item *next; fz_item *prev; fz_store *store; - fz_store_type *type; + const fz_store_type *type; }; struct fz_store_s @@ -389,7 +389,7 @@ touch(fz_store *store, fz_item *item) } void * -fz_store_item(fz_context *ctx, void *key, void *val_, size_t itemsize, fz_store_type *type) +fz_store_item(fz_context *ctx, void *key, void *val_, size_t itemsize, const fz_store_type *type) { fz_item *item = NULL; size_t size; @@ -525,7 +525,7 @@ fz_store_item(fz_context *ctx, void *key, void *val_, size_t itemsize, fz_store_ } void * -fz_find_item(fz_context *ctx, fz_store_drop_fn *drop, void *key, fz_store_type *type) +fz_find_item(fz_context *ctx, fz_store_drop_fn *drop, void *key, const fz_store_type *type) { fz_item *item; fz_store *store = ctx->store; @@ -578,7 +578,7 @@ fz_find_item(fz_context *ctx, fz_store_drop_fn *drop, void *key, fz_store_type * } void -fz_remove_item(fz_context *ctx, fz_store_drop_fn *drop, void *key, fz_store_type *type) +fz_remove_item(fz_context *ctx, fz_store_drop_fn *drop, void *key, const fz_store_type *type) { fz_item *item; fz_store *store = ctx->store; @@ -832,7 +832,7 @@ fz_shrink_store(fz_context *ctx, unsigned int percent) return success; } -void fz_filter_store(fz_context *ctx, fz_store_filter_fn *fn, void *arg, fz_store_type *type) +void fz_filter_store(fz_context *ctx, fz_store_filter_fn *fn, void *arg, const fz_store_type *type) { fz_store *store; fz_item *item, *prev, *remove; diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c index 3cced0d8..d993188c 100644 --- a/source/pdf/pdf-font.c +++ b/source/pdf/pdf-font.c @@ -963,7 +963,9 @@ hail_mary_print_key(fz_context *ctx, fz_output *out, void *key_) fz_write_printf(ctx, out, "hail mary "); } -static fz_store_type hail_mary_store_type = +static int hail_mary_store_key; /* Dummy */ + +static const fz_store_type hail_mary_store_type = { hail_mary_make_hash_key, hail_mary_keep_key, @@ -978,7 +980,7 @@ pdf_load_hail_mary_font(fz_context *ctx, pdf_document *doc) pdf_font_desc *fontdesc; pdf_font_desc *existing; - if ((fontdesc = fz_find_item(ctx, pdf_drop_font_imp, &hail_mary_store_type, &hail_mary_store_type)) != NULL) + if ((fontdesc = fz_find_item(ctx, pdf_drop_font_imp, &hail_mary_store_key, &hail_mary_store_type)) != NULL) { return fontdesc; } @@ -986,7 +988,7 @@ pdf_load_hail_mary_font(fz_context *ctx, pdf_document *doc) /* FIXME: Get someone with a clue about fonts to fix this */ fontdesc = pdf_load_simple_font_by_name(ctx, doc, NULL, "Helvetica"); - existing = fz_store_item(ctx, &hail_mary_store_type, fontdesc, fontdesc->size, &hail_mary_store_type); + existing = fz_store_item(ctx, &hail_mary_store_key, fontdesc, fontdesc->size, &hail_mary_store_type); assert(existing == NULL); (void)existing; /* Silence warning in release builds */ diff --git a/source/pdf/pdf-store.c b/source/pdf/pdf-store.c index e29e7ccb..c2d0669e 100644 --- a/source/pdf/pdf-store.c +++ b/source/pdf/pdf-store.c @@ -41,7 +41,7 @@ pdf_print_key(fz_context *ctx, fz_output *out, void *key_) pdf_print_obj(ctx, out, key, 0); } -static fz_store_type pdf_obj_store_type = +static const fz_store_type pdf_obj_store_type = { pdf_make_hash_key, pdf_keep_key, -- cgit v1.2.3