diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2017-10-11 20:39:11 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2017-11-22 23:09:51 +0100 |
commit | 65996a1ffa6937ae5fa1825ef9cac09927163c1c (patch) | |
tree | 87f6c3cd3ef8b7cfd2fd8737a513ddba45538410 /source/fitz/output-png.c | |
parent | 46fe810563b4ca04b9804fd1163d22ca76cfa4ac (diff) | |
download | mupdf-65996a1ffa6937ae5fa1825ef9cac09927163c1c.tar.xz |
Use custom allocator everywhere zlib is used.
Diffstat (limited to 'source/fitz/output-png.c')
-rw-r--r-- | source/fitz/output-png.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/source/fitz/output-png.c b/source/fitz/output-png.c index 59dbba94..15fb41f0 100644 --- a/source/fitz/output-png.c +++ b/source/fitz/output-png.c @@ -4,6 +4,16 @@ #include <zlib.h> +static void *zalloc_outpng(void *opaque, unsigned int items, unsigned int size) +{ + return fz_malloc_array_no_throw(opaque, items, size); +} + +static void zfree_outpng(void *opaque, void *address) +{ + fz_free(opaque, address); +} + static inline void big32(unsigned char *buf, unsigned int v) { buf[0] = (v >> 24) & 0xff; @@ -194,6 +204,9 @@ png_write_band(fz_context *ctx, fz_band_writer *writer_, int stride, int band_st writer->csize = compressBound(writer->usize); writer->udata = fz_malloc(ctx, writer->usize); writer->cdata = fz_malloc(ctx, writer->csize); + writer->stream.opaque = ctx; + writer->stream.zalloc = zalloc_outpng; + writer->stream.zfree = zfree_outpng; err = deflateInit(&writer->stream, Z_DEFAULT_COMPRESSION); if (err != Z_OK) fz_throw(ctx, FZ_ERROR_GENERIC, "compression error %d", err); |