diff options
author | Robin Watts <robin.watts@artifex.com> | 2016-03-21 18:52:20 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2016-03-21 19:03:51 +0000 |
commit | e5eb6ade2cfbc3493d4462b4aa8c92bd26f7a0c8 (patch) | |
tree | c6adbcd356b0a797e52d30d2ef0794c124f7dc15 /source/fitz | |
parent | c4d3a9142761a567fce9f66946a917e087c0de67 (diff) | |
download | mupdf-e5eb6ade2cfbc3493d4462b4aa8c92bd26f7a0c8.tar.xz |
Tweak NULL output code.
In the quest for better mutool draw timings, make fz_outputs going
to /dev/null be represented by a NULL pointer.
Spot this in the output routines and just exit.
Diffstat (limited to 'source/fitz')
-rw-r--r-- | source/fitz/bitmap.c | 6 | ||||
-rw-r--r-- | source/fitz/output.c | 31 | ||||
-rw-r--r-- | source/fitz/pixmap.c | 6 |
3 files changed, 13 insertions, 30 deletions
diff --git a/source/fitz/bitmap.c b/source/fitz/bitmap.c index 540d54cf..b610737a 100644 --- a/source/fitz/bitmap.c +++ b/source/fitz/bitmap.c @@ -342,6 +342,9 @@ fz_write_pbm_band(fz_context *ctx, fz_output *out, fz_bitmap *bitmap) if (bitmap->n != 1) fz_throw(ctx, FZ_ERROR_GENERIC, "too many color components in bitmap"); + if (!out) + return; + p = bitmap->samples; h = bitmap->h; bytestride = (bitmap->w + 7) >> 3; @@ -361,6 +364,9 @@ fz_write_pkm_band(fz_context *ctx, fz_output *out, fz_bitmap *bitmap) if (bitmap->n != 4) fz_throw(ctx, FZ_ERROR_GENERIC, "wrong number of color components in bitmap"); + if (!out) + return; + p = bitmap->samples; h = bitmap->h; w = bitmap->w; diff --git a/source/fitz/output.c b/source/fitz/output.c index 1904ee85..9ea2d169 100644 --- a/source/fitz/output.c +++ b/source/fitz/output.c @@ -62,35 +62,6 @@ fz_new_output_with_file_ptr(fz_context *ctx, FILE *file, int close) return out; } -static void -null_write(fz_context *ctx, void *opaque, const void *buffer, int count) -{ - return; -} - -static void -null_seek(fz_context *ctx, void *opaque, fz_off_t off, int whence) -{ -} - -static fz_off_t -null_tell(fz_context *ctx, void *opaque) -{ - return 0; -} - -static fz_output * -null_filename(fz_context *ctx) -{ - fz_output *out = fz_malloc_struct(ctx, fz_output); - out->opaque = NULL; - out->write = null_write; - out->seek = null_seek; - out->tell = null_tell; - out->close = NULL; - return out; -} - fz_output * fz_new_output_with_path(fz_context *ctx, const char *filename, int append) { @@ -98,7 +69,7 @@ fz_new_output_with_path(fz_context *ctx, const char *filename, int append) FILE *file; if (!strcmp(filename, "/dev/null") || !fz_strcasecmp(filename, "nul:")) - return null_filename(ctx); + return NULL; file = fz_fopen(filename, append ? "ab" : "wb"); if (!file) diff --git a/source/fitz/pixmap.c b/source/fitz/pixmap.c index 2b72cd00..018b5907 100644 --- a/source/fitz/pixmap.c +++ b/source/fitz/pixmap.c @@ -587,6 +587,9 @@ fz_write_pnm_band(fz_context *ctx, fz_output *out, int w, int h, int n, int band int start = band * bandheight; int end = start + bandheight; + if (!out) + return; + if (end > h) end = h; end -= start; @@ -699,6 +702,9 @@ fz_write_pam_band(fz_context *ctx, fz_output *out, int w, int h, int n, int band if (!savealpha && dn > 1) dn--; + if (!out) + return; + if (end > h) end = h; end -= start; |