diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2017-04-27 12:43:00 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2017-04-27 15:12:03 +0200 |
commit | c586d072fd786e66851173f5ddd31241ad28f3e6 (patch) | |
tree | d6db1b68dc122f8349513633ae76a73ed353b69b /source/xps/xps-zip.c | |
parent | ce680b96e207c90429eb702c5ee4b9bec177fdfd (diff) | |
download | mupdf-c586d072fd786e66851173f5ddd31241ad28f3e6.tar.xz |
Avoid typecasting function pointers in subclasses.
Do the typecasting in the functions instead, reducing the risk
of function prototype mismatches.
Diffstat (limited to 'source/xps/xps-zip.c')
-rw-r--r-- | source/xps/xps-zip.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/source/xps/xps-zip.c b/source/xps/xps-zip.c index 5efccab4..a17894ea 100644 --- a/source/xps/xps-zip.c +++ b/source/xps/xps-zip.c @@ -110,7 +110,7 @@ xps_has_part(fz_context *ctx, xps_document *doc, char *name) return 0; } -static xps_document * +static fz_document * xps_open_document_with_directory(fz_context *ctx, const char *directory) { xps_document *doc; @@ -129,10 +129,10 @@ xps_open_document_with_directory(fz_context *ctx, const char *directory) fz_rethrow(ctx); } - return doc; + return (fz_document*)doc; } -xps_document * +fz_document * xps_open_document_with_stream(fz_context *ctx, fz_stream *file) { xps_document *doc; @@ -151,16 +151,16 @@ xps_open_document_with_stream(fz_context *ctx, fz_stream *file) fz_rethrow(ctx); } - return doc; + return (fz_document*)doc; } -xps_document * +fz_document * xps_open_document(fz_context *ctx, const char *filename) { char buf[2048]; fz_stream *file; char *p; - xps_document *doc; + fz_document *doc; if (strstr(filename, "/_rels/.rels") || strstr(filename, "\\_rels\\.rels")) { @@ -181,12 +181,13 @@ xps_open_document(fz_context *ctx, const char *filename) fz_catch(ctx) fz_rethrow(ctx); - return doc; + return (fz_document*)doc; } static void -xps_drop_document(fz_context *ctx, xps_document *doc) +xps_drop_document(fz_context *ctx, fz_document *doc_) { + xps_document *doc = (xps_document*)doc_; xps_font_cache *font, *next; if (doc->zip) @@ -208,7 +209,7 @@ xps_drop_document(fz_context *ctx, xps_document *doc) } static int -xps_lookup_metadata(fz_context *ctx, xps_document *doc, const char *key, char *buf, int size) +xps_lookup_metadata(fz_context *ctx, fz_document *doc_, const char *key, char *buf, int size) { if (!strcmp(key, "format")) return (int)fz_strlcpy(buf, "XPS", size); @@ -219,10 +220,10 @@ static void xps_init_document(fz_context *ctx, xps_document *doc) { doc->super.refs = 1; - doc->super.drop_document = (fz_document_drop_fn*)xps_drop_document; - doc->super.load_outline = (fz_document_load_outline_fn*)xps_load_outline; - doc->super.resolve_link = (fz_document_resolve_link_fn*)xps_lookup_link_target; - doc->super.count_pages = (fz_document_count_pages_fn*)xps_count_pages; - doc->super.load_page = (fz_document_load_page_fn*)xps_load_page; - doc->super.lookup_metadata = (fz_document_lookup_metadata_fn*)xps_lookup_metadata; + doc->super.drop_document = xps_drop_document; + doc->super.load_outline = xps_load_outline; + doc->super.resolve_link = xps_lookup_link_target; + doc->super.count_pages = xps_count_pages; + doc->super.load_page = xps_load_page; + doc->super.lookup_metadata = xps_lookup_metadata; } |