From 681039767f2ccc72e236246178893eb0989169c9 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 20 Jan 2015 16:42:29 +0100 Subject: Rename fz_close_* and fz_free_* to fz_drop_*. Rename fz_close to fz_drop_stream. Rename fz_close_archive to fz_drop_archive. Rename fz_close_output to fz_drop_output. Rename fz_free_* to fz_drop_*. Rename pdf_free_* to pdf_drop_*. Rename xps_free_* to xps_drop_*. --- source/cbz/mucbz.c | 4 ++-- source/fitz/bbox-device.c | 4 ++-- source/fitz/buffer.c | 2 +- source/fitz/colorspace.c | 20 ++++++++++---------- source/fitz/compressed-buffer.c | 2 +- source/fitz/context.c | 8 ++++---- source/fitz/device.c | 6 +++--- source/fitz/draw-device.c | 24 ++++++++++++------------ source/fitz/draw-edge.c | 4 ++-- source/fitz/draw-imp.h | 2 +- source/fitz/draw-scale-simple.c | 2 +- source/fitz/filter-basic.c | 28 ++++++++++++++-------------- source/fitz/filter-dct.c | 8 ++++---- source/fitz/filter-fax.c | 4 ++-- source/fitz/filter-flate.c | 4 ++-- source/fitz/filter-jbig2.c | 8 ++++---- source/fitz/filter-leech.c | 4 ++-- source/fitz/filter-lzw.c | 4 ++-- source/fitz/filter-predict.c | 4 ++-- source/fitz/font.c | 6 +++--- source/fitz/glyph.c | 12 ++++++------ source/fitz/hash.c | 2 +- source/fitz/image.c | 16 ++++++++-------- source/fitz/link.c | 6 +++--- source/fitz/list-device.c | 4 ++-- source/fitz/load-tiff.c | 12 ++++++------ source/fitz/outline.c | 6 +++--- source/fitz/output-pcl.c | 4 ++-- source/fitz/output-pwg.c | 4 ++-- source/fitz/output.c | 2 +- source/fitz/pixmap.c | 14 +++++++------- source/fitz/shade.c | 12 ++++++------ source/fitz/stext-device.c | 20 ++++++++++---------- source/fitz/store.c | 32 ++++++++++++++++---------------- source/fitz/stream-open.c | 2 +- source/fitz/stream-read.c | 2 +- source/fitz/svg-device.c | 6 +++--- source/fitz/test-device.c | 6 +++--- source/fitz/tree.c | 10 +++++----- source/fitz/unzip.c | 8 ++++---- source/fitz/xml.c | 6 +++--- source/img/muimage.c | 4 ++-- source/pdf/pdf-annot-edit.c | 4 ++-- source/pdf/pdf-annot.c | 10 +++++----- source/pdf/pdf-appearance.c | 22 +++++++++++----------- source/pdf/pdf-cmap-load.c | 6 +++--- source/pdf/pdf-cmap.c | 4 ++-- source/pdf/pdf-colorspace.c | 6 +++--- source/pdf/pdf-crypt.c | 26 +++++++++++++------------- source/pdf/pdf-device.c | 4 ++-- source/pdf/pdf-font.c | 8 ++++---- source/pdf/pdf-form.c | 2 +- source/pdf/pdf-function.c | 10 +++++----- source/pdf/pdf-image.c | 2 +- source/pdf/pdf-interpret.c | 12 ++++++------ source/pdf/pdf-object.c | 10 +++++----- source/pdf/pdf-op-buffer.c | 4 ++-- source/pdf/pdf-outline.c | 2 +- source/pdf/pdf-page.c | 10 +++++----- source/pdf/pdf-pattern.c | 8 ++++---- source/pdf/pdf-pkcs7.c | 4 ++-- source/pdf/pdf-repair.c | 2 +- source/pdf/pdf-shade.c | 4 ++-- source/pdf/pdf-store.c | 8 ++++---- source/pdf/pdf-stream.c | 12 ++++++------ source/pdf/pdf-write.c | 2 +- source/pdf/pdf-xobject.c | 10 +++++----- source/pdf/pdf-xref.c | 26 +++++++++++++------------- source/tiff/mutiff.c | 4 ++-- source/tools/mjsgen.c | 2 +- source/tools/mudraw.c | 40 ++++++++++++++++++++-------------------- source/tools/pdfclean.c | 2 +- source/tools/pdfextract.c | 2 +- source/tools/pdfinfo.c | 4 ++-- source/tools/pdfposter.c | 2 +- source/tools/pdfshow.c | 4 ++-- source/xps/xps-doc.c | 36 ++++++++++++++++++------------------ source/xps/xps-glyphs.c | 2 +- source/xps/xps-gradient.c | 4 ++-- source/xps/xps-image.c | 2 +- source/xps/xps-outline.c | 4 ++-- source/xps/xps-resource.c | 8 ++++---- source/xps/xps-tile.c | 4 ++-- source/xps/xps-zip.c | 10 +++++----- 84 files changed, 343 insertions(+), 343 deletions(-) (limited to 'source') diff --git a/source/cbz/mucbz.c b/source/cbz/mucbz.c index 6951e798..72b6a185 100644 --- a/source/cbz/mucbz.c +++ b/source/cbz/mucbz.c @@ -145,7 +145,7 @@ cbz_open_document(fz_context *ctx, const char *filename) } fz_always(ctx) { - fz_close(file); + fz_drop_stream(file); } fz_catch(ctx) { @@ -158,7 +158,7 @@ cbz_open_document(fz_context *ctx, const char *filename) void cbz_close_document(cbz_document *doc) { - fz_close_archive(doc->ctx, doc->zip); + fz_drop_archive(doc->ctx, doc->zip); fz_free(doc->ctx, (char **)doc->page); fz_free(doc->ctx, doc); } diff --git a/source/fitz/bbox-device.c b/source/fitz/bbox-device.c index 8a298fe1..b8e63b56 100644 --- a/source/fitz/bbox-device.c +++ b/source/fitz/bbox-device.c @@ -180,7 +180,7 @@ fz_bbox_end_tile(fz_device *dev) } static void -fz_bbox_free_user(fz_device *dev) +fz_bbox_drop_user(fz_device *dev) { fz_bbox_data *data = dev->user; if (data->top > 0) @@ -198,7 +198,7 @@ fz_new_bbox_device(fz_context *ctx, fz_rect *result) user->top = 0; user->ignore = 0; dev = fz_new_device(ctx, user); - dev->free_user = fz_bbox_free_user; + dev->drop_user = fz_bbox_drop_user; dev->fill_path = fz_bbox_fill_path; dev->stroke_path = fz_bbox_stroke_path; diff --git a/source/fitz/buffer.c b/source/fitz/buffer.c index acfdc20a..12de453a 100644 --- a/source/fitz/buffer.c +++ b/source/fitz/buffer.c @@ -370,7 +370,7 @@ fz_test_buffer_write(fz_context *ctx) fprintf(stderr, "Copied buffer is different!\n"); fz_seek(stm, 0, 0); } - fz_close(stm); + fz_drop_stream(stm); fz_drop_buffer(ctx, master); fz_drop_buffer(ctx, copy); } diff --git a/source/fitz/colorspace.c b/source/fitz/colorspace.c index 87b49413..f1dff20c 100644 --- a/source/fitz/colorspace.c +++ b/source/fitz/colorspace.c @@ -3,7 +3,7 @@ #define SLOWCMYK void -fz_free_colorspace_imp(fz_context *ctx, fz_storable *cs_) +fz_drop_colorspace_imp(fz_context *ctx, fz_storable *cs_) { fz_colorspace *cs = (fz_colorspace *)cs_; @@ -15,8 +15,8 @@ fz_free_colorspace_imp(fz_context *ctx, fz_storable *cs_) fz_colorspace * fz_new_colorspace(fz_context *ctx, char *name, int n) { - fz_colorspace *cs = Memento_label(fz_malloc(ctx, sizeof(fz_colorspace)), "fz_colorspace"); - FZ_INIT_STORABLE(cs, 1, fz_free_colorspace_imp); + fz_colorspace *cs = fz_malloc_struct(ctx, fz_colorspace); + FZ_INIT_STORABLE(cs, 1, fz_drop_colorspace_imp); cs->size = sizeof(fz_colorspace); fz_strlcpy(cs->name, name, sizeof cs->name); cs->n = n; @@ -169,10 +169,10 @@ static void rgb_to_cmyk(fz_context *ctx, fz_colorspace *cs, const float *rgb, fl cmyk[3] = k; } -static fz_colorspace k_default_gray = { {-1, fz_free_colorspace_imp}, 0, "DeviceGray", 1, gray_to_rgb, rgb_to_gray }; -static fz_colorspace k_default_rgb = { {-1, fz_free_colorspace_imp}, 0, "DeviceRGB", 3, rgb_to_rgb, rgb_to_rgb }; -static fz_colorspace k_default_bgr = { {-1, fz_free_colorspace_imp}, 0, "DeviceBGR", 3, bgr_to_rgb, rgb_to_bgr }; -static fz_colorspace k_default_cmyk = { {-1, fz_free_colorspace_imp}, 0, "DeviceCMYK", 4, cmyk_to_rgb, rgb_to_cmyk }; +static fz_colorspace k_default_gray = { {-1, fz_drop_colorspace_imp}, 0, "DeviceGray", 1, gray_to_rgb, rgb_to_gray }; +static fz_colorspace k_default_rgb = { {-1, fz_drop_colorspace_imp}, 0, "DeviceRGB", 3, rgb_to_rgb, rgb_to_rgb }; +static fz_colorspace k_default_bgr = { {-1, fz_drop_colorspace_imp}, 0, "DeviceBGR", 3, bgr_to_rgb, rgb_to_bgr }; +static fz_colorspace k_default_cmyk = { {-1, fz_drop_colorspace_imp}, 0, "DeviceCMYK", 4, cmyk_to_rgb, rgb_to_cmyk }; static fz_colorspace *fz_default_gray = &k_default_gray; static fz_colorspace *fz_default_rgb = &k_default_rgb; @@ -948,7 +948,7 @@ fz_std_conv_pixmap(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src) } } - fz_free_hash(ctx, lookup); + fz_drop_hash(ctx, lookup); } } @@ -1337,7 +1337,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ } fz_catch(ctx) { - fz_free_hash(ctx, cached->hash); + fz_drop_hash(ctx, cached->hash); fz_rethrow(ctx); } } @@ -1363,6 +1363,6 @@ void fz_fin_cached_color_converter(fz_color_converter *cc_) if (v) fz_free(ctx, v); } - fz_free_hash(ctx, cc->hash); + fz_drop_hash(ctx, cc->hash); fz_free(ctx, cc); } diff --git a/source/fitz/compressed-buffer.c b/source/fitz/compressed-buffer.c index 1a863309..48f88eff 100644 --- a/source/fitz/compressed-buffer.c +++ b/source/fitz/compressed-buffer.c @@ -4,7 +4,7 @@ * pulled into cmapdump.c */ void -fz_free_compressed_buffer(fz_context *ctx, fz_compressed_buffer *buf) +fz_drop_compressed_buffer(fz_context *ctx, fz_compressed_buffer *buf) { if (!buf) return; diff --git a/source/fitz/context.c b/source/fitz/context.c index 36ad879f..b3ca9b5b 100644 --- a/source/fitz/context.c +++ b/source/fitz/context.c @@ -43,7 +43,7 @@ fz_keep_id_context(fz_context *ctx) } void -fz_free_context(fz_context *ctx) +fz_drop_context(fz_context *ctx) { if (!ctx) return; @@ -52,7 +52,7 @@ fz_free_context(fz_context *ctx) fz_drop_document_handler_context(ctx); fz_drop_glyph_cache_context(ctx); fz_drop_store_context(ctx); - fz_free_aa_context(ctx); + fz_drop_aa_context(ctx); fz_drop_colorspace_context(ctx); fz_drop_font_context(ctx); fz_drop_id_context(ctx); @@ -117,7 +117,7 @@ new_context_phase1(fz_alloc_context *alloc, fz_locks_context *locks) cleanup: fprintf(stderr, "cannot create context (phase 1)\n"); - fz_free_context(ctx); + fz_drop_context(ctx); return NULL; } @@ -155,7 +155,7 @@ fz_new_context_imp(fz_alloc_context *alloc, fz_locks_context *locks, unsigned in fz_catch(ctx) { fprintf(stderr, "cannot create context (phase 2)\n"); - fz_free_context(ctx); + fz_drop_context(ctx); return NULL; } return ctx; diff --git a/source/fitz/device.c b/source/fitz/device.c index a13cd470..cb57256e 100644 --- a/source/fitz/device.c +++ b/source/fitz/device.c @@ -13,12 +13,12 @@ fz_new_device(fz_context *ctx, void *user) } void -fz_free_device(fz_device *dev) +fz_drop_device(fz_device *dev) { if (dev == NULL) return; - if (dev->free_user) - dev->free_user(dev); + if (dev->drop_user) + dev->drop_user(dev); fz_free(dev->ctx, dev->container); fz_free(dev->ctx, dev); } diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c index a8d745af..8701cd31 100644 --- a/source/fitz/draw-device.c +++ b/source/fitz/draw-device.c @@ -1753,7 +1753,7 @@ static fz_store_type fz_tile_store_type = }; static void -fz_free_tile_record_imp(fz_context *ctx, fz_storable *storable) +fz_drop_tile_record_imp(fz_context *ctx, fz_storable *storable) { tile_record *tr = (tile_record *)(void *)storable; @@ -1774,7 +1774,7 @@ static tile_record * fz_new_tile_record(fz_context *ctx, fz_pixmap *dest, fz_pixmap *shape) { tile_record *tile = fz_malloc_struct(ctx, tile_record); - FZ_INIT_STORABLE(tile, 1, fz_free_tile_record_imp); + FZ_INIT_STORABLE(tile, 1, fz_drop_tile_record_imp); tile->dest = fz_keep_pixmap(ctx, dest); tile->shape = fz_keep_pixmap(ctx, shape); return tile; @@ -1828,7 +1828,7 @@ fz_draw_begin_tile(fz_device *devp, const fz_rect *area, const fz_rect *view, fl tk.ctm[3] = ctm->d; tk.id = id; - tile = fz_find_item(ctx, fz_free_tile_record_imp, &tk, &fz_tile_store_type); + tile = fz_find_item(ctx, fz_drop_tile_record_imp, &tk, &fz_tile_store_type); if (tile) { state[1].dest = fz_keep_pixmap(ctx, tile->dest); @@ -2038,7 +2038,7 @@ fz_draw_end_tile(fz_device *devp) } static void -fz_draw_free_user(fz_device *devp) +fz_draw_drop_user(fz_device *devp) { fz_draw_device *dev = devp->user; fz_context *ctx = dev->ctx; @@ -2062,9 +2062,9 @@ fz_draw_free_user(fz_device *devp) */ if (dev->stack != &dev->init_stack[0]) fz_free(ctx, dev->stack); - fz_free_scale_cache(ctx, dev->cache_x); - fz_free_scale_cache(ctx, dev->cache_y); - fz_free_gel(dev->gel); + fz_drop_scale_cache(ctx, dev->cache_x); + fz_drop_scale_cache(ctx, dev->cache_y); + fz_drop_gel(dev->gel); fz_free(ctx, dev); } @@ -2098,13 +2098,13 @@ fz_new_draw_device(fz_context *ctx, fz_pixmap *dest) } fz_catch(ctx) { - fz_free_scale_cache(ctx, ddev->cache_x); - fz_free_scale_cache(ctx, ddev->cache_y); - fz_free_gel(ddev->gel); + fz_drop_scale_cache(ctx, ddev->cache_x); + fz_drop_scale_cache(ctx, ddev->cache_y); + fz_drop_gel(ddev->gel); fz_free(ctx, ddev); fz_rethrow(ctx); } - dev->free_user = fz_draw_free_user; + dev->drop_user = fz_draw_drop_user; dev->fill_path = fz_draw_fill_path; dev->stroke_path = fz_draw_stroke_path; @@ -2177,7 +2177,7 @@ fz_bound_path_accurate(fz_context *ctx, fz_irect *bbox, const fz_irect *scissor, else fz_flatten_fill_path(gel, path, ctm, flatness); fz_bound_gel(gel, bbox); - fz_free_gel(gel); + fz_drop_gel(gel); return bbox; } diff --git a/source/fitz/draw-edge.c b/source/fitz/draw-edge.c index c8d94155..e1fd5f37 100644 --- a/source/fitz/draw-edge.c +++ b/source/fitz/draw-edge.c @@ -48,7 +48,7 @@ void fz_copy_aa_context(fz_context *dst, fz_context *src) memcpy(dst->aa, src->aa, sizeof(*src->aa)); } -void fz_free_aa_context(fz_context *ctx) +void fz_drop_aa_context(fz_context *ctx) { #ifndef AA_BITS fz_free(ctx, ctx->aa); @@ -228,7 +228,7 @@ fz_reset_gel(fz_gel *gel, const fz_irect *clip) } void -fz_free_gel(fz_gel *gel) +fz_drop_gel(fz_gel *gel) { if (gel == NULL) return; diff --git a/source/fitz/draw-imp.h b/source/fitz/draw-imp.h index 9b9e50c0..b5f4690d 100644 --- a/source/fitz/draw-imp.h +++ b/source/fitz/draw-imp.h @@ -12,7 +12,7 @@ void fz_insert_gel(fz_gel *gel, float x0, float y0, float x1, float y1); void fz_reset_gel(fz_gel *gel, const fz_irect *clip); void fz_sort_gel(fz_gel *gel); fz_irect *fz_bound_gel(const fz_gel *gel, fz_irect *bbox); -void fz_free_gel(fz_gel *gel); +void fz_drop_gel(fz_gel *gel); int fz_is_rect_gel(fz_gel *gel); fz_rect *fz_gel_scissor(const fz_gel *gel, fz_rect *rect); diff --git a/source/fitz/draw-scale-simple.c b/source/fitz/draw-scale-simple.c index 939464a1..5651e1f4 100644 --- a/source/fitz/draw-scale-simple.c +++ b/source/fitz/draw-scale-simple.c @@ -1498,7 +1498,7 @@ cleanup: } void -fz_free_scale_cache(fz_context *ctx, fz_scale_cache *sc) +fz_drop_scale_cache(fz_context *ctx, fz_scale_cache *sc) { if (!sc) return; diff --git a/source/fitz/filter-basic.c b/source/fitz/filter-basic.c index 807364bc..1b4eaefb 100644 --- a/source/fitz/filter-basic.c +++ b/source/fitz/filter-basic.c @@ -50,7 +50,7 @@ close_null(fz_context *ctx, void *state_) struct null_filter *state = (struct null_filter *)state_; fz_stream *chain = state->chain; fz_free(ctx, state); - fz_close(chain); + fz_drop_stream(chain); } static fz_stream * @@ -77,7 +77,7 @@ fz_open_null(fz_stream *chain, int len, int offset) } fz_catch(ctx) { - fz_close(chain); + fz_drop_stream(chain); fz_rethrow(ctx); } @@ -123,7 +123,7 @@ next_concat(fz_stream *stm, int max) break; } state->current++; - fz_close(state->chain[state->current-1]); + fz_drop_stream(state->chain[state->current-1]); if (state->pad) { stm->rp = (&state->ws_buf)+1; @@ -147,7 +147,7 @@ close_concat(fz_context *ctx, void *state_) for (i = state->current; i < state->count; i++) { - fz_close(state->chain[i]); + fz_drop_stream(state->chain[i]); } fz_free(ctx, state); } @@ -293,7 +293,7 @@ close_ahxd(fz_context *ctx, void *state_) fz_ahxd *state = (fz_ahxd *)state_; fz_stream *chain = state->chain; fz_free(ctx, state); - fz_close(chain); + fz_drop_stream(chain); } static fz_stream * @@ -317,7 +317,7 @@ fz_open_ahxd(fz_stream *chain) } fz_catch(ctx) { - fz_close(chain); + fz_drop_stream(chain); fz_rethrow(ctx); } @@ -445,7 +445,7 @@ close_a85d(fz_context *ctx, void *state_) fz_stream *chain = state->chain; fz_free(ctx, state); - fz_close(chain); + fz_drop_stream(chain); } static fz_stream * @@ -469,7 +469,7 @@ fz_open_a85d(fz_stream *chain) } fz_catch(ctx) { - fz_close(chain); + fz_drop_stream(chain); fz_rethrow(ctx); } @@ -564,7 +564,7 @@ close_rld(fz_context *ctx, void *state_) fz_stream *chain = state->chain; fz_free(ctx, state); - fz_close(chain); + fz_drop_stream(chain); } static fz_stream * @@ -590,7 +590,7 @@ fz_open_rld(fz_stream *chain) } fz_catch(ctx) { - fz_close(chain); + fz_drop_stream(chain); fz_rethrow(ctx); } @@ -635,7 +635,7 @@ close_arc4(fz_context *ctx, void *state_) fz_stream *chain = state->chain; fz_free(ctx, state); - fz_close(chain); + fz_drop_stream(chain); } static fz_stream * @@ -659,7 +659,7 @@ fz_open_arc4(fz_stream *chain, unsigned char *key, unsigned keylen) } fz_catch(ctx) { - fz_close(chain); + fz_drop_stream(chain); fz_rethrow(ctx); } @@ -745,7 +745,7 @@ close_aesd(fz_context *ctx, void *state_) fz_stream *chain = state->chain; fz_free(ctx, state); - fz_close(chain); + fz_drop_stream(chain); } static fz_stream * @@ -776,7 +776,7 @@ fz_open_aesd(fz_stream *chain, unsigned char *key, unsigned keylen) fz_catch(ctx) { fz_free(ctx, state); - fz_close(chain); + fz_drop_stream(chain); fz_rethrow(ctx); } diff --git a/source/fitz/filter-dct.c b/source/fitz/filter-dct.c index 344dbdbf..9495b899 100644 --- a/source/fitz/filter-dct.c +++ b/source/fitz/filter-dct.c @@ -308,8 +308,8 @@ skip: fz_dct_mem_term(state); fz_free(ctx, state->scanline); - fz_close(state->chain); - fz_close(state->jpegtables); + fz_drop_stream(state->chain); + fz_drop_stream(state->jpegtables); fz_free(ctx, state); } @@ -344,8 +344,8 @@ fz_open_dctd(fz_stream *chain, int color_transform, int l2factor, fz_stream *jpe fz_catch(ctx) { fz_free(ctx, state); - fz_close(chain); - fz_close(jpegtables); + fz_drop_stream(chain); + fz_drop_stream(jpegtables); fz_rethrow(ctx); } diff --git a/source/fitz/filter-fax.c b/source/fitz/filter-fax.c index 70692338..134c2ae5 100644 --- a/source/fitz/filter-fax.c +++ b/source/fitz/filter-fax.c @@ -778,7 +778,7 @@ close_faxd(fz_context *ctx, void *state_) while (i--) fz_unread_byte(fax->chain); - fz_close(fax->chain); + fz_drop_stream(fax->chain); fz_free(ctx, fax->ref); fz_free(ctx, fax->dst); fz_free(ctx, fax); @@ -848,7 +848,7 @@ fz_open_faxd(fz_stream *chain, fz_free(ctx, fax->ref); } fz_free(ctx, fax); - fz_close(chain); + fz_drop_stream(chain); fz_rethrow(ctx); } diff --git a/source/fitz/filter-flate.c b/source/fitz/filter-flate.c index b66661cc..764e819a 100644 --- a/source/fitz/filter-flate.c +++ b/source/fitz/filter-flate.c @@ -93,7 +93,7 @@ close_flated(fz_context *ctx, void *state_) if (code != Z_OK) fz_warn(ctx, "zlib error: inflateEnd: %s", state->z.msg); - fz_close(state->chain); + fz_drop_stream(state->chain); fz_free(ctx, state); } @@ -134,7 +134,7 @@ fz_open_flated(fz_stream *chain, int window_bits) if (state && code == Z_OK) inflateEnd(&state->z); fz_free(ctx, state); - fz_close(chain); + fz_drop_stream(chain); fz_rethrow(ctx); } return fz_new_stream(ctx, state, next_flated, close_flated, rebind_flated); diff --git a/source/fitz/filter-jbig2.c b/source/fitz/filter-jbig2.c index 98919dcb..0e624da6 100644 --- a/source/fitz/filter-jbig2.c +++ b/source/fitz/filter-jbig2.c @@ -35,7 +35,7 @@ close_jbig2d(fz_context *ctx, void *state_) if (state->gctx) fz_drop_jbig2_globals(ctx, state->gctx); jbig2_ctx_free(state->ctx); - fz_close(state->chain); + fz_drop_stream(state->chain); fz_free(ctx, state); } @@ -112,14 +112,14 @@ fz_load_jbig2_globals(fz_context *ctx, unsigned char *data, int size) Jbig2Ctx *jctx = jbig2_ctx_new(NULL, JBIG2_OPTIONS_EMBEDDED, NULL, error_callback, ctx); jbig2_data_in(jctx, data, size); - FZ_INIT_STORABLE(globals, 1, fz_free_jbig2_globals_imp); + FZ_INIT_STORABLE(globals, 1, fz_drop_jbig2_globals_imp); globals->gctx = jbig2_make_global_ctx(jctx); return globals; } void -fz_free_jbig2_globals_imp(fz_context *ctx, fz_storable *globals_) +fz_drop_jbig2_globals_imp(fz_context *ctx, fz_storable *globals_) { fz_jbig2_globals *globals = (fz_jbig2_globals *)globals_; jbig2_global_ctx_free(globals->gctx); @@ -153,7 +153,7 @@ fz_open_jbig2d(fz_stream *chain, fz_jbig2_globals *globals) jbig2_ctx_free(state->ctx); } fz_free(ctx, state); - fz_close(chain); + fz_drop_stream(chain); fz_rethrow(ctx); } diff --git a/source/fitz/filter-leech.c b/source/fitz/filter-leech.c index 321e31d7..67a43a29 100644 --- a/source/fitz/filter-leech.c +++ b/source/fitz/filter-leech.c @@ -40,7 +40,7 @@ close_leech(fz_context *ctx, void *state_) { fz_leech *state = (fz_leech *)state_; - fz_close(state->chain); + fz_drop_stream(state->chain); fz_free(ctx, state); } @@ -68,7 +68,7 @@ fz_open_leecher(fz_stream *chain, fz_buffer *buffer) fz_catch(ctx) { fz_free(ctx, state); - fz_close(chain); + fz_drop_stream(chain); fz_rethrow(ctx); } return fz_new_stream(ctx, state, next_leech, close_leech, rebind_leech); diff --git a/source/fitz/filter-lzw.c b/source/fitz/filter-lzw.c index 16b5253a..4f8fdd31 100644 --- a/source/fitz/filter-lzw.c +++ b/source/fitz/filter-lzw.c @@ -189,7 +189,7 @@ close_lzwd(fz_context *ctx, void *state_) { fz_lzwd *lzw = (fz_lzwd *)state_; fz_sync_bits(lzw->chain); - fz_close(lzw->chain); + fz_drop_stream(lzw->chain); fz_free(ctx, lzw); } @@ -243,7 +243,7 @@ fz_open_lzwd(fz_stream *chain, int early_change) fz_catch(ctx) { fz_free(ctx, lzw); - fz_close(chain); + fz_drop_stream(chain); fz_rethrow(ctx); } diff --git a/source/fitz/filter-predict.c b/source/fitz/filter-predict.c index 3aaa6ee9..a5c93bfd 100644 --- a/source/fitz/filter-predict.c +++ b/source/fitz/filter-predict.c @@ -209,7 +209,7 @@ static void close_predict(fz_context *ctx, void *state_) { fz_predict *state = (fz_predict *)state_; - fz_close(state->chain); + fz_drop_stream(state->chain); fz_free(ctx, state->in); fz_free(ctx, state->out); fz_free(ctx, state->ref); @@ -288,7 +288,7 @@ fz_open_predict(fz_stream *chain, int predictor, int columns, int colors, int bp fz_free(ctx, state->out); } fz_free(ctx, state); - fz_close(chain); + fz_drop_stream(chain); fz_rethrow(ctx); } diff --git a/source/fitz/font.c b/source/fitz/font.c index 598931e8..08379b0f 100644 --- a/source/fitz/font.c +++ b/source/fitz/font.c @@ -1065,7 +1065,7 @@ fz_prepare_t3_glyph(fz_context *ctx, fz_font *font, int gid, int nested_depth) FZ_DEVFLAG_LINEWIDTH_UNDEFINED; font->t3run(font->t3doc, font->t3resources, contents, dev, &fz_identity, NULL, 0); font->t3flags[gid] = dev->flags; - fz_free_device(dev); + fz_drop_device(dev); } static fz_rect * @@ -1091,7 +1091,7 @@ fz_bound_t3_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, } fz_always(ctx) { - fz_free_device(dev); + fz_drop_device(dev); } fz_catch(ctx) { @@ -1168,7 +1168,7 @@ fz_render_t3_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, const fz_matr } fz_always(ctx) { - fz_free_device(dev); + fz_drop_device(dev); } fz_catch(ctx) { diff --git a/source/fitz/glyph.c b/source/fitz/glyph.c index 0bf4c7fd..8e514751 100644 --- a/source/fitz/glyph.c +++ b/source/fitz/glyph.c @@ -15,7 +15,7 @@ fz_drop_glyph(fz_context *ctx, fz_glyph *glyph) } static void -fz_free_glyph_imp(fz_context *ctx, fz_storable *glyph_) +fz_drop_glyph_imp(fz_context *ctx, fz_storable *glyph_) { fz_glyph *glyph = (fz_glyph *)glyph_; @@ -136,7 +136,7 @@ fz_new_glyph_from_pixmap(fz_context *ctx, fz_pixmap *pix) if (pix->n != 1 || pix->w * pix->h < RLE_THRESHOLD) { glyph = fz_malloc_struct(ctx, fz_glyph); - FZ_INIT_STORABLE(glyph, 1, fz_free_glyph_imp); + FZ_INIT_STORABLE(glyph, 1, fz_drop_glyph_imp); glyph->x = pix->x; glyph->y = pix->y; glyph->w = pix->w; @@ -181,7 +181,7 @@ fz_new_glyph_from_8bpp_data(fz_context *ctx, int x, int y, int w, int h, unsigne size = h * w; fill = h * sizeof(int); glyph = fz_malloc(ctx, sizeof(fz_glyph) + size); - FZ_INIT_STORABLE(glyph, 1, fz_free_glyph_imp); + FZ_INIT_STORABLE(glyph, 1, fz_drop_glyph_imp); glyph->x = x; glyph->y = y; glyph->w = w; @@ -288,7 +288,7 @@ fz_new_glyph_from_8bpp_data(fz_context *ctx, int x, int y, int w, int h, unsigne * critical. */ try_pixmap: glyph = fz_resize_array(ctx, glyph, 1, sizeof(fz_glyph)); - FZ_INIT_STORABLE(glyph, 1, fz_free_glyph_imp); + FZ_INIT_STORABLE(glyph, 1, fz_drop_glyph_imp); pix = fz_new_pixmap_from_8bpp_data(ctx, x, y, w, h, orig_sp, span); glyph->x = pix->x; glyph->y = pix->y; @@ -329,7 +329,7 @@ fz_new_glyph_from_1bpp_data(fz_context *ctx, int x, int y, int w, int h, unsigne size = h * w; fill = h * sizeof(int); glyph = fz_malloc(ctx, sizeof(fz_glyph) + size); - FZ_INIT_STORABLE(glyph, 1, fz_free_glyph_imp); + FZ_INIT_STORABLE(glyph, 1, fz_drop_glyph_imp); glyph->x = x; glyph->y = y; glyph->w = w; @@ -420,7 +420,7 @@ fz_new_glyph_from_1bpp_data(fz_context *ctx, int x, int y, int w, int h, unsigne * critical. */ try_pixmap: glyph = fz_resize_array(ctx, glyph, 1, sizeof(fz_glyph)); - FZ_INIT_STORABLE(glyph, 1, fz_free_glyph_imp); + FZ_INIT_STORABLE(glyph, 1, fz_drop_glyph_imp); pix = fz_new_pixmap_from_1bpp_data(ctx, x, y, w, h, orig_sp, span); glyph->x = pix->x; glyph->y = pix->y; diff --git a/source/fitz/hash.c b/source/fitz/hash.c index 708d72f2..acd22334 100644 --- a/source/fitz/hash.c +++ b/source/fitz/hash.c @@ -94,7 +94,7 @@ fz_hash_get_val(fz_context *ctx, fz_hash_table *table, int idx) } void -fz_free_hash(fz_context *ctx, fz_hash_table *table) +fz_drop_hash(fz_context *ctx, fz_hash_table *table) { fz_free(ctx, table->ents); fz_free(ctx, table); diff --git a/source/fitz/image.c b/source/fitz/image.c index 09d39043..e7096ab4 100644 --- a/source/fitz/image.c +++ b/source/fitz/image.c @@ -216,7 +216,7 @@ fz_decomp_image_from_stream(fz_context *ctx, fz_stream *stm, fz_image *image, in } fz_always(ctx) { - fz_close(stm); + fz_drop_stream(stm); } fz_catch(ctx) { @@ -239,14 +239,14 @@ fz_decomp_image_from_stream(fz_context *ctx, fz_stream *stm, fz_image *image, in } void -fz_free_image(fz_context *ctx, fz_storable *image_) +fz_drop_image_imp(fz_context *ctx, fz_storable *image_) { fz_image *image = (fz_image *)image_; if (image == NULL) return; fz_drop_pixmap(ctx, image->tile); - fz_free_compressed_buffer(ctx, image->buffer); + fz_drop_compressed_buffer(ctx, image->buffer); fz_drop_colorspace(ctx, image->colorspace); fz_drop_image(ctx, image->mask); fz_free(ctx, image); @@ -293,7 +293,7 @@ fz_image_get_pixmap(fz_context *ctx, fz_image *image, int w, int h) key.l2factor = l2factor; do { - tile = fz_find_item(ctx, fz_free_pixmap_imp, &key, &fz_image_store_type); + tile = fz_find_item(ctx, fz_drop_pixmap_imp, &key, &fz_image_store_type); if (tile) return tile; key.l2factor--; @@ -393,7 +393,7 @@ fz_new_image_from_pixmap(fz_context *ctx, fz_pixmap *pixmap, fz_image *mask) fz_try(ctx) { image = fz_malloc_struct(ctx, fz_image); - FZ_INIT_STORABLE(image, 1, fz_free_image); + FZ_INIT_STORABLE(image, 1, fz_drop_image_imp); image->w = pixmap->w; image->h = pixmap->h; image->n = pixmap->n; @@ -427,7 +427,7 @@ fz_new_image(fz_context *ctx, int w, int h, int bpc, fz_colorspace *colorspace, fz_try(ctx) { image = fz_malloc_struct(ctx, fz_image); - FZ_INIT_STORABLE(image, 1, fz_free_image); + FZ_INIT_STORABLE(image, 1, fz_drop_image_imp); image->get_pixmap = fz_image_get_pixmap; image->w = w; image->h = h; @@ -458,7 +458,7 @@ fz_new_image(fz_context *ctx, int w, int h, int bpc, fz_colorspace *colorspace, } fz_catch(ctx) { - fz_free_compressed_buffer(ctx, buffer); + fz_drop_compressed_buffer(ctx, buffer); fz_rethrow(ctx); } @@ -538,7 +538,7 @@ fz_new_image_from_buffer(fz_context *ctx, fz_buffer *buffer) } fz_catch(ctx) { - fz_free_compressed_buffer(ctx, bc); + fz_drop_compressed_buffer(ctx, bc); fz_rethrow(ctx); } diff --git a/source/fitz/link.c b/source/fitz/link.c index 30dca222..152d48ea 100644 --- a/source/fitz/link.c +++ b/source/fitz/link.c @@ -1,7 +1,7 @@ #include "mupdf/fitz.h" void -fz_free_link_dest(fz_context *ctx, fz_link_dest *dest) +fz_drop_link_dest(fz_context *ctx, fz_link_dest *dest) { switch (dest->kind) { @@ -35,7 +35,7 @@ fz_new_link(fz_context *ctx, const fz_rect *bbox, fz_link_dest dest) } fz_catch(ctx) { - fz_free_link_dest(ctx, &dest); + fz_drop_link_dest(ctx, &dest); fz_rethrow(ctx); } link->dest = dest; @@ -58,7 +58,7 @@ fz_drop_link(fz_context *ctx, fz_link *link) while (link && --link->refs == 0) { fz_link *next = link->next; - fz_free_link_dest(ctx, &link->dest); + fz_drop_link_dest(ctx, &link->dest); fz_free(ctx, link); link = next; } diff --git a/source/fitz/list-device.c b/source/fitz/list-device.c index 42590bab..c6e8011f 100644 --- a/source/fitz/list-device.c +++ b/source/fitz/list-device.c @@ -592,7 +592,7 @@ fz_new_list_device(fz_context *ctx, fz_display_list *list) } static void -fz_free_display_list(fz_context *ctx, fz_storable *list_) +fz_drop_display_list_imp(fz_context *ctx, fz_storable *list_) { fz_display_list *list = (fz_display_list *)list_; fz_display_node *node; @@ -613,7 +613,7 @@ fz_display_list * fz_new_display_list(fz_context *ctx) { fz_display_list *list = fz_malloc_struct(ctx, fz_display_list); - FZ_INIT_STORABLE(list, 1, fz_free_display_list); + FZ_INIT_STORABLE(list, 1, fz_drop_display_list_imp); list->first = NULL; list->last = NULL; list->len = 0; diff --git a/source/fitz/load-tiff.c b/source/fitz/load-tiff.c index 671e5146..77fb816d 100644 --- a/source/fitz/load-tiff.c +++ b/source/fitz/load-tiff.c @@ -145,7 +145,7 @@ static void fz_decode_tiff_uncompressed(struct tiff *tiff, fz_stream *stm, unsigned char *wp, int wlen) { fz_read(stm, wp, wlen); - fz_close(stm); + fz_drop_stream(stm); } static void @@ -153,7 +153,7 @@ fz_decode_tiff_packbits(struct tiff *tiff, fz_stream *chain, unsigned char *wp, { fz_stream *stm = fz_open_rld(chain); fz_read(stm, wp, wlen); - fz_close(stm); + fz_drop_stream(stm); } static void @@ -161,7 +161,7 @@ fz_decode_tiff_lzw(struct tiff *tiff, fz_stream *chain, unsigned char *wp, int w { fz_stream *stm = fz_open_lzwd(chain, 1); fz_read(stm, wp, wlen); - fz_close(stm); + fz_drop_stream(stm); } static void @@ -169,7 +169,7 @@ fz_decode_tiff_flate(struct tiff *tiff, fz_stream *chain, unsigned char *wp, int { fz_stream *stm = fz_open_flated(chain, 15); fz_read(stm, wp, wlen); - fz_close(stm); + fz_drop_stream(stm); } static void @@ -183,7 +183,7 @@ fz_decode_tiff_fax(struct tiff *tiff, int comp, fz_stream *chain, unsigned char k, 0, encoded_byte_align, tiff->imagewidth, tiff->imagelength, 0, black_is_1); fz_read(stm, wp, wlen); - fz_close(stm); + fz_drop_stream(stm); } static void @@ -198,7 +198,7 @@ fz_decode_tiff_jpeg(struct tiff *tiff, fz_stream *chain, unsigned char *wp, int color_transform = 0; stm = fz_open_dctd(chain, color_transform, 0, jpegtables); fz_read(stm, wp, wlen); - fz_close(stm); + fz_drop_stream(stm); } static inline int getcomp(unsigned char *line, int x, int bpc) diff --git a/source/fitz/outline.c b/source/fitz/outline.c index e26fd378..7a019883 100644 --- a/source/fitz/outline.c +++ b/source/fitz/outline.c @@ -1,14 +1,14 @@ #include "mupdf/fitz.h" void -fz_free_outline(fz_context *ctx, fz_outline *outline) +fz_drop_outline(fz_context *ctx, fz_outline *outline) { while (outline) { fz_outline *next = outline->next; - fz_free_outline(ctx, outline->down); + fz_drop_outline(ctx, outline->down); fz_free(ctx, outline->title); - fz_free_link_dest(ctx, &outline->dest); + fz_drop_link_dest(ctx, &outline->dest); fz_free(ctx, outline); outline = next; } diff --git a/source/fitz/output-pcl.c b/source/fitz/output-pcl.c index 0eeab8d3..90695eb7 100644 --- a/source/fitz/output-pcl.c +++ b/source/fitz/output-pcl.c @@ -816,7 +816,7 @@ fz_write_pcl(fz_context *ctx, fz_pixmap *pixmap, char *filename, int append, fz_ } fz_always(ctx) { - fz_close_output(out); + fz_drop_output(out); fclose(fp); } fz_catch(ctx) @@ -846,7 +846,7 @@ fz_write_pcl_bitmap(fz_context *ctx, fz_bitmap *bitmap, char *filename, int appe } fz_always(ctx) { - fz_close_output(out); + fz_drop_output(out); fclose(fp); } fz_catch(ctx) diff --git a/source/fitz/output-pwg.c b/source/fitz/output-pwg.c index c6d1a0b5..a2107db6 100644 --- a/source/fitz/output-pwg.c +++ b/source/fitz/output-pwg.c @@ -283,7 +283,7 @@ fz_write_pwg(fz_context *ctx, fz_pixmap *pixmap, char *filename, int append, con } fz_always(ctx) { - fz_close_output(out); + fz_drop_output(out); fclose(fp); } fz_catch(ctx) @@ -315,7 +315,7 @@ fz_write_pwg_bitmap(fz_context *ctx, fz_bitmap *bitmap, char *filename, int appe } fz_always(ctx) { - fz_close_output(out); + fz_drop_output(out); fclose(fp); } fz_catch(ctx) diff --git a/source/fitz/output.c b/source/fitz/output.c index fe63de92..8f5a4a0f 100644 --- a/source/fitz/output.c +++ b/source/fitz/output.c @@ -71,7 +71,7 @@ fz_new_output_to_filename(fz_context *ctx, const char *filename) } void -fz_close_output(fz_output *out) +fz_drop_output(fz_output *out) { if (!out) return; diff --git a/source/fitz/pixmap.c b/source/fitz/pixmap.c index 9ce8ffba..d6a74ea1 100644 --- a/source/fitz/pixmap.c +++ b/source/fitz/pixmap.c @@ -13,7 +13,7 @@ fz_drop_pixmap(fz_context *ctx, fz_pixmap *pix) } void -fz_free_pixmap_imp(fz_context *ctx, fz_storable *pix_) +fz_drop_pixmap_imp(fz_context *ctx, fz_storable *pix_) { fz_pixmap *pix = (fz_pixmap *)pix_; @@ -33,7 +33,7 @@ fz_new_pixmap_with_data(fz_context *ctx, fz_colorspace *colorspace, int w, int h fz_throw(ctx, FZ_ERROR_GENERIC, "Illegal dimensions for pixmap %d %d", w, h); pix = fz_malloc_struct(ctx, fz_pixmap); - FZ_INIT_STORABLE(pix, 1, fz_free_pixmap_imp); + FZ_INIT_STORABLE(pix, 1, fz_drop_pixmap_imp); pix->x = 0; pix->y = 0; pix->w = w; @@ -583,7 +583,7 @@ fz_write_pnm(fz_context *ctx, fz_pixmap *pixmap, char *filename) fz_output *out = fz_new_output_to_filename(ctx, filename); fz_output_pnm_header(out, pixmap->w, pixmap->h, pixmap->n); fz_output_pnm_band(out, pixmap->w, pixmap->h, pixmap->n, 0, pixmap->h, pixmap->samples); - fz_close_output(out); + fz_drop_output(out); } /* @@ -645,7 +645,7 @@ fz_write_pam(fz_context *ctx, fz_pixmap *pixmap, char *filename, int savealpha) fz_output *out = fz_new_output_to_filename(ctx, filename); fz_output_pam_header(out, pixmap->w, pixmap->h, pixmap->n, savealpha); fz_output_pam_band(out, pixmap->w, pixmap->h, pixmap->n, 0, pixmap->h, pixmap->samples, savealpha); - fz_close_output(out); + fz_drop_output(out); } /* @@ -690,7 +690,7 @@ fz_write_png(fz_context *ctx, fz_pixmap *pixmap, char *filename, int savealpha) fz_always(ctx) { fz_output_png_trailer(out, poc); - fz_close_output(out); + fz_drop_output(out); } fz_catch(ctx) { @@ -929,7 +929,7 @@ png_from_pixmap(fz_context *ctx, fz_pixmap *pix, int drop) fz_always(ctx) { fz_drop_pixmap(ctx, drop ? pix : pix2); - fz_close_output(out); + fz_drop_output(out); } fz_catch(ctx) { @@ -1029,7 +1029,7 @@ fz_write_tga(fz_context *ctx, fz_pixmap *pixmap, const char *filename, int savea } fz_write(out, "\0\0\0\0\0\0\0\0TRUEVISION-XFILE.\0", 26); - fz_close_output(out); + fz_drop_output(out); } unsigned int diff --git a/source/fitz/shade.c b/source/fitz/shade.c index 4c6b1472..01ada9a4 100644 --- a/source/fitz/shade.c +++ b/source/fitz/shade.c @@ -362,7 +362,7 @@ fz_process_mesh_type4(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz } fz_always(ctx) { - fz_close(stream); + fz_drop_stream(stream); } fz_catch(ctx) { @@ -422,7 +422,7 @@ fz_process_mesh_type5(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz { fz_free(ctx, ref); fz_free(ctx, buf); - fz_close(stream); + fz_drop_stream(stream); } fz_catch(ctx) { @@ -790,7 +790,7 @@ fz_process_mesh_type6(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz } fz_always(ctx) { - fz_close(stream); + fz_drop_stream(stream); } fz_catch(ctx) { @@ -903,7 +903,7 @@ fz_process_mesh_type7(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz } fz_always(ctx) { - fz_close(stream); + fz_drop_stream(stream); } fz_catch(ctx) { @@ -1043,7 +1043,7 @@ fz_keep_shade(fz_context *ctx, fz_shade *shade) } void -fz_free_shade_imp(fz_context *ctx, fz_storable *shade_) +fz_drop_shade_imp(fz_context *ctx, fz_storable *shade_) { fz_shade *shade = (fz_shade *)shade_; @@ -1051,7 +1051,7 @@ fz_free_shade_imp(fz_context *ctx, fz_storable *shade_) fz_drop_colorspace(ctx, shade->colorspace); if (shade->type == FZ_FUNCTION_BASED) fz_free(ctx, shade->u.f.fn_vals); - fz_free_compressed_buffer(ctx, shade->buffer); + fz_drop_compressed_buffer(ctx, shade->buffer); fz_free(ctx, shade); } diff --git a/source/fitz/stext-device.c b/source/fitz/stext-device.c index 20e5e525..f963eb19 100644 --- a/source/fitz/stext-device.c +++ b/source/fitz/stext-device.c @@ -368,7 +368,7 @@ fz_new_text_sheet(fz_context *ctx) } void -fz_free_text_sheet(fz_context *ctx, fz_text_sheet *sheet) +fz_drop_text_sheet(fz_context *ctx, fz_text_sheet *sheet) { fz_text_style *style; @@ -447,7 +447,7 @@ fz_new_text_page(fz_context *ctx) } static void -fz_free_text_line_contents(fz_context *ctx, fz_text_line *line) +fz_drop_text_line_contents(fz_context *ctx, fz_text_line *line) { fz_text_span *span, *next; for (span = line->first_span; span; span=next) @@ -459,19 +459,19 @@ fz_free_text_line_contents(fz_context *ctx, fz_text_line *line) } static void -fz_free_text_block(fz_context *ctx, fz_text_block *block) +fz_drop_text_block(fz_context *ctx, fz_text_block *block) { fz_text_line *line; if (block == NULL) return; for (line = block->lines; line < block->lines + block->len; line++) - fz_free_text_line_contents(ctx, line); + fz_drop_text_line_contents(ctx, line); fz_free(ctx, block->lines); fz_free(ctx, block); } static void -fz_free_image_block(fz_context *ctx, fz_image_block *block) +fz_drop_image_block(fz_context *ctx, fz_image_block *block) { if (block == NULL) return; @@ -481,7 +481,7 @@ fz_free_image_block(fz_context *ctx, fz_image_block *block) } void -fz_free_text_page(fz_context *ctx, fz_text_page *page) +fz_drop_text_page(fz_context *ctx, fz_text_page *page) { fz_page_block *block; if (page == NULL) @@ -491,10 +491,10 @@ fz_free_text_page(fz_context *ctx, fz_text_page *page) switch (block->type) { case FZ_PAGE_BLOCK_TEXT: - fz_free_text_block(ctx, block->u.text); + fz_drop_text_block(ctx, block->u.text); break; case FZ_PAGE_BLOCK_IMAGE: - fz_free_image_block(ctx, block->u.image); + fz_drop_image_block(ctx, block->u.image); break; } } @@ -994,7 +994,7 @@ fz_text_end_page(fz_device *dev) } static void -fz_text_free_user(fz_device *dev) +fz_text_drop_user(fz_device *dev) { fz_text_device *tdev = dev->user; free_span_soup(tdev->spans); @@ -1017,7 +1017,7 @@ fz_new_text_device(fz_context *ctx, fz_text_sheet *sheet, fz_text_page *page) dev->hints = FZ_IGNORE_IMAGE | FZ_IGNORE_SHADE; dev->begin_page = fz_text_begin_page; dev->end_page = fz_text_end_page; - dev->free_user = fz_text_free_user; + dev->drop_user = fz_text_drop_user; dev->fill_text = fz_text_fill_text; dev->stroke_text = fz_text_stroke_text; dev->clip_text = fz_text_clip_text; diff --git a/source/fitz/store.c b/source/fitz/store.c index cf0e3536..315f8e81 100644 --- a/source/fitz/store.c +++ b/source/fitz/store.c @@ -88,7 +88,7 @@ fz_drop_storable(fz_context *ctx, fz_storable *s) } fz_unlock(ctx, FZ_LOCK_ALLOC); if (do_free) - s->free(ctx, s); + s->drop(ctx, s); } static void @@ -113,14 +113,14 @@ evict(fz_context *ctx, fz_item *item) if (item->type->make_hash_key) { fz_store_hash hash = { NULL }; - hash.free = item->val->free; + hash.drop = item->val->drop; if (item->type->make_hash_key(&hash, item->key)) fz_hash_remove(ctx, store->hash, &hash); } fz_unlock(ctx, FZ_LOCK_ALLOC); if (drop) - item->val->free(ctx, item->val); - /* Always drops the key and free the item */ + item->val->drop(ctx, item->val); + /* Always drops the key and drop the item */ item->type->drop_key(ctx, item->key); fz_free(ctx, item); fz_lock(ctx, FZ_LOCK_ALLOC); @@ -250,7 +250,7 @@ fz_store_item(fz_context *ctx, void *key, void *val_, unsigned int itemsize, fz_ if (type->make_hash_key) { - hash.free = val->free; + hash.drop = val->drop; use_hash = type->make_hash_key(&hash, key); } @@ -347,7 +347,7 @@ fz_store_item(fz_context *ctx, void *key, void *val_, unsigned int itemsize, fz_ } void * -fz_find_item(fz_context *ctx, fz_store_free_fn *free, void *key, fz_store_type *type) +fz_find_item(fz_context *ctx, fz_store_drop_fn *drop, void *key, fz_store_type *type) { fz_item *item; fz_store *store = ctx->store; @@ -362,7 +362,7 @@ fz_find_item(fz_context *ctx, fz_store_free_fn *free, void *key, fz_store_type * if (type->make_hash_key) { - hash.free = free; + hash.drop = drop; use_hash = type->make_hash_key(&hash, key); } @@ -377,7 +377,7 @@ fz_find_item(fz_context *ctx, fz_store_free_fn *free, void *key, fz_store_type * /* Others we have to hunt for slowly */ for (item = store->head; item; item = item->next) { - if (item->val->free == free && !type->cmp_key(item->key, key)) + if (item->val->drop == drop && !type->cmp_key(item->key, key)) break; } } @@ -400,17 +400,17 @@ fz_find_item(fz_context *ctx, fz_store_free_fn *free, void *key, fz_store_type * } void -fz_remove_item(fz_context *ctx, fz_store_free_fn *free, void *key, fz_store_type *type) +fz_remove_item(fz_context *ctx, fz_store_drop_fn *drop, void *key, fz_store_type *type) { fz_item *item; fz_store *store = ctx->store; - int drop; + int dodrop; fz_store_hash hash = { NULL }; int use_hash = 0; if (type->make_hash_key) { - hash.free = free; + hash.drop = drop; use_hash = type->make_hash_key(&hash, key); } @@ -426,7 +426,7 @@ fz_remove_item(fz_context *ctx, fz_store_free_fn *free, void *key, fz_store_type { /* Others we have to hunt for slowly */ for (item = store->head; item; item = item->next) - if (item->val->free == free && !type->cmp_key(item->key, key)) + if (item->val->drop == drop && !type->cmp_key(item->key, key)) break; } if (item) @@ -445,10 +445,10 @@ fz_remove_item(fz_context *ctx, fz_store_free_fn *free, void *key, fz_store_type else store->head = item->next; } - drop = (item->val->refs > 0 && --item->val->refs == 0); + dodrop = (item->val->refs > 0 && --item->val->refs == 0); fz_unlock(ctx, FZ_LOCK_ALLOC); - if (drop) - item->val->free(ctx, item->val); + if (dodrop) + item->val->drop(ctx, item->val); type->drop_key(ctx, item->key); fz_free(ctx, item); } @@ -497,7 +497,7 @@ fz_drop_store_context(fz_context *ctx) return; fz_empty_store(ctx); - fz_free_hash(ctx, ctx->store->hash); + fz_drop_hash(ctx, ctx->store->hash); fz_free(ctx, ctx->store); ctx->store = NULL; } diff --git a/source/fitz/stream-open.c b/source/fitz/stream-open.c index 3e51e733..c5808a73 100644 --- a/source/fitz/stream-open.c +++ b/source/fitz/stream-open.c @@ -58,7 +58,7 @@ fz_keep_stream(fz_stream *stm) } void -fz_close(fz_stream *stm) +fz_drop_stream(fz_stream *stm) { if (!stm) return; diff --git a/source/fitz/stream-read.c b/source/fitz/stream-read.c index 3144974e..49e1c1a3 100644 --- a/source/fitz/stream-read.c +++ b/source/fitz/stream-read.c @@ -177,7 +177,7 @@ fz_read_file(fz_context *ctx, const char *filename) } fz_always(ctx) { - fz_close(stm); + fz_drop_stream(stm); } fz_catch(ctx) { diff --git a/source/fitz/svg-device.c b/source/fitz/svg-device.c index f90557b5..b4e10fe4 100644 --- a/source/fitz/svg-device.c +++ b/source/fitz/svg-device.c @@ -1027,7 +1027,7 @@ svg_dev_end_tile(fz_device *dev) } static void -svg_dev_free_user(fz_device *dev) +svg_dev_drop_user(fz_device *dev) { svg_device *sdev = dev->user; fz_context *ctx = sdev->ctx; @@ -1035,7 +1035,7 @@ svg_dev_free_user(fz_device *dev) fz_free(ctx, sdev->tiles); fz_drop_buffer(ctx, sdev->defs_buffer); - fz_close_output(sdev->defs); + fz_drop_output(sdev->defs); fz_printf(out, "\n"); @@ -1072,7 +1072,7 @@ fz_device *fz_new_svg_device(fz_context *ctx, fz_output *out, float page_width, } dev->rebind = svg_rebind; - dev->free_user = svg_dev_free_user; + dev->drop_user = svg_dev_drop_user; dev->fill_path = svg_dev_fill_path; dev->stroke_path = svg_dev_stroke_path; diff --git a/source/fitz/test-device.c b/source/fitz/test-device.c index 9c778ce1..919bda98 100644 --- a/source/fitz/test-device.c +++ b/source/fitz/test-device.c @@ -152,7 +152,7 @@ fz_test_fill_image(fz_device *dev, fz_image *image, const fz_matrix *ctm, float { *t->is_color = 1; dev->hints |= FZ_IGNORE_IMAGE; - fz_close(stream); + fz_drop_stream(stream); fz_throw(ctx, FZ_ERROR_ABORT, "Page found as color; stopping interpretation"); break; } @@ -183,7 +183,7 @@ fz_test_fill_image(fz_device *dev, fz_image *image, const fz_matrix *ctm, float } fz_fin_cached_color_converter(&cc); } - fz_close(stream); + fz_drop_stream(stream); return; } @@ -287,7 +287,7 @@ fz_new_test_device(fz_context *ctx, int *is_color, float threshold) dev->fill_shade = fz_test_fill_shade; dev->fill_image = fz_test_fill_image; dev->fill_image_mask = fz_test_fill_image_mask; - dev->free_user = fz_test_free; + dev->drop_user = fz_test_free; *t->is_color = 0; diff --git a/source/fitz/tree.c b/source/fitz/tree.c index ca94a45b..18fb6548 100644 --- a/source/fitz/tree.c +++ b/source/fitz/tree.c @@ -89,17 +89,17 @@ fz_tree *fz_tree_insert(fz_context *ctx, fz_tree *node, const char *key, void *v } } -void fz_free_tree(fz_context *ctx, fz_tree *node, void (*freefunc)(fz_context *ctx, void *value)) +void fz_drop_tree(fz_context *ctx, fz_tree *node, void (*dropfunc)(fz_context *ctx, void *value)) { if (node) { if (node->left != &sentinel) - fz_free_tree(ctx, node->left, freefunc); + fz_drop_tree(ctx, node->left, dropfunc); if (node->right != &sentinel) - fz_free_tree(ctx, node->right, freefunc); + fz_drop_tree(ctx, node->right, dropfunc); fz_free(ctx, node->key); - if (freefunc) - freefunc(ctx, node->value); + if (dropfunc) + dropfunc(ctx, node->value); } } diff --git a/source/fitz/unzip.c b/source/fitz/unzip.c index f13a9ace..bafc4146 100644 --- a/source/fitz/unzip.c +++ b/source/fitz/unzip.c @@ -452,13 +452,13 @@ fz_list_archive_entry(fz_context *ctx, fz_archive *zip, int idx) } void -fz_close_archive(fz_context *ctx, fz_archive *zip) +fz_drop_archive(fz_context *ctx, fz_archive *zip) { int i; if (zip) { fz_free(ctx, zip->directory); - fz_close(zip->file); + fz_drop_stream(zip->file); for (i = 0; i < zip->count; ++i) fz_free(ctx, zip->table[i].name); fz_free(ctx, zip->table); @@ -497,7 +497,7 @@ fz_open_archive_with_stream(fz_context *ctx, fz_stream *file) } fz_catch(ctx) { - fz_close_archive(ctx, zip); + fz_drop_archive(ctx, zip); fz_rethrow(ctx); } @@ -517,7 +517,7 @@ fz_open_archive(fz_context *ctx, const char *filename) } fz_always(ctx) { - fz_close(file); + fz_drop_stream(file); } fz_catch(ctx) { diff --git a/source/fitz/xml.c b/source/fitz/xml.c index 0d370331..424a6bdf 100644 --- a/source/fitz/xml.c +++ b/source/fitz/xml.c @@ -205,7 +205,7 @@ static void xml_free_attribute(fz_context *ctx, struct attribute *att) } } -void fz_free_xml(fz_context *ctx, fz_xml *item) +void fz_drop_xml(fz_context *ctx, fz_xml *item) { while (item) { @@ -215,7 +215,7 @@ void fz_free_xml(fz_context *ctx, fz_xml *item) if (item->atts) xml_free_attribute(ctx, item->atts); if (item->down) - fz_free_xml(ctx, item->down); + fz_drop_xml(ctx, item->down); fz_free(ctx, item); item = next; } @@ -618,7 +618,7 @@ fz_parse_xml(fz_context *ctx, unsigned char *s, int n, int preserve_white) } fz_catch(ctx) { - fz_free_xml(ctx, root.down); + fz_drop_xml(ctx, root.down); fz_rethrow(ctx); } diff --git a/source/img/muimage.c b/source/img/muimage.c index 21fd6261..30f9b043 100644 --- a/source/img/muimage.c +++ b/source/img/muimage.c @@ -62,7 +62,7 @@ image_open_document(fz_context *ctx, const char *filename) } fz_always(ctx) { - fz_close(file); + fz_drop_stream(file); } fz_catch(ctx) { @@ -77,7 +77,7 @@ image_close_document(image_document *doc) { fz_context *ctx = doc->ctx; fz_drop_image(ctx, doc->image); - fz_close(doc->file); + fz_drop_stream(doc->file); fz_free(ctx, doc); } diff --git a/source/pdf/pdf-annot-edit.c b/source/pdf/pdf-annot-edit.c index 1e82accb..719f92bd 100644 --- a/source/pdf/pdf-annot-edit.c +++ b/source/pdf/pdf-annot-edit.c @@ -140,7 +140,7 @@ pdf_create_annot(pdf_document *doc, pdf_page *page, fz_annot_type type) /* Linking must be done after any call that might throw because - pdf_free_annot below actually frees a list. Put the new annot + pdf_drop_annot below actually frees a list. Put the new annot at the end of the list, so that it will be drawn last. */ *page->annot_tailp = annot; @@ -155,7 +155,7 @@ pdf_create_annot(pdf_document *doc, pdf_page *page, fz_annot_type type) } fz_catch(ctx) { - pdf_free_annot(ctx, annot); + pdf_drop_annot(ctx, annot); fz_rethrow(ctx); } diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c index 6b786985..72f5cd8e 100644 --- a/source/pdf/pdf-annot.c +++ b/source/pdf/pdf-annot.c @@ -369,7 +369,7 @@ pdf_load_link_annots(pdf_document *doc, pdf_obj *annots, const fz_matrix *page_c } void -pdf_free_annot(fz_context *ctx, pdf_annot *annot) +pdf_drop_annot(fz_context *ctx, pdf_annot *annot) { pdf_annot *next; @@ -500,7 +500,7 @@ pdf_load_annots(pdf_document *doc, pdf_page *page, pdf_obj *annots) } fz_catch(ctx) { - pdf_free_annot(ctx, page->annots); + pdf_drop_annot(ctx, page->annots); page->annots = NULL; fz_rethrow(ctx); } @@ -573,7 +573,7 @@ pdf_load_annots(pdf_document *doc, pdf_page *page, pdf_obj *annots) { if (fz_caught(ctx) == FZ_ERROR_TRYLATER) { - pdf_free_annot(ctx, page->annots); + pdf_drop_annot(ctx, page->annots); page->annots = NULL; fz_rethrow(ctx); } @@ -584,8 +584,8 @@ pdf_load_annots(pdf_document *doc, pdf_page *page, pdf_obj *annots) { /* Move to next item in the linked list, dropping this one */ *itr = annot->next; - annot->next = NULL; /* Required because pdf_free_annot follows the "next" chain */ - pdf_free_annot(ctx, annot); + annot->next = NULL; /* Required because pdf_drop_annot follows the "next" chain */ + pdf_drop_annot(ctx, annot); } } diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c index 8ff3993e..a8d8d6ef 100644 --- a/source/pdf/pdf-appearance.c +++ b/source/pdf/pdf-appearance.c @@ -147,7 +147,7 @@ void pdf_parse_da(fz_context *ctx, char *da, pdf_da_info *di) fz_always(ctx) { fz_free(ctx, name); - fz_close(str); + fz_drop_stream(str); pdf_lexbuf_fin(&lbuf); } fz_catch(ctx) @@ -809,7 +809,7 @@ static int get_matrix(pdf_document *doc, pdf_xobject *form, int q, fz_matrix *mt } fz_always(ctx) { - fz_close(str); + fz_drop_stream(str); pdf_lexbuf_fin(&lbuf); } fz_catch(ctx) @@ -1064,8 +1064,8 @@ static void update_marked_content(pdf_document *doc, pdf_xobject *form, fz_buffe } fz_always(ctx) { - fz_close(str_outer); - fz_close(str_inner); + fz_drop_stream(str_outer); + fz_drop_stream(str_inner); fz_drop_buffer(ctx, newbuf); pdf_lexbuf_fin(&lbuf); } @@ -1387,7 +1387,7 @@ void pdf_set_annot_appearance(pdf_document *doc, pdf_annot *annot, fz_rect *rect dev = pdf_new_pdf_device(doc, ap_obj, pdf_dict_gets(ap_obj, "Resources"), &mat); fz_run_display_list(disp_list, dev, &ctm, &fz_infinite_rect, NULL); - fz_free_device(dev); + fz_drop_device(dev); /* Mark the appearance as changed - required for partial update */ xobj = pdf_load_xobject(doc, ap_obj); @@ -1406,7 +1406,7 @@ void pdf_set_annot_appearance(pdf_document *doc, pdf_annot *annot, fz_rect *rect } fz_catch(ctx) { - fz_free_device(dev); + fz_drop_device(dev); fz_rethrow(ctx); } } @@ -1528,7 +1528,7 @@ void pdf_set_markup_appearance(pdf_document *doc, pdf_annot *annot, float color[ fz_always(ctx) { fz_free(ctx, qp); - fz_free_device(dev); + fz_drop_device(dev); fz_drop_stroke_state(ctx, stroke); fz_drop_path(ctx, path); fz_drop_display_list(ctx, strike_list); @@ -1662,7 +1662,7 @@ void pdf_update_ink_appearance(pdf_document *doc, pdf_annot *annot) fz_always(ctx) { fz_drop_colorspace(ctx, cs); - fz_free_device(dev); + fz_drop_device(dev); fz_drop_stroke_state(ctx, stroke); fz_drop_path(ctx, path); fz_drop_display_list(ctx, strike_list); @@ -1905,7 +1905,7 @@ void pdf_update_text_annot_appearance(pdf_document *doc, pdf_annot *annot) } fz_always(ctx) { - fz_free_device(dev); + fz_drop_device(dev); fz_drop_display_list(ctx, dlist); fz_drop_stroke_state(ctx, stroke); fz_drop_path(ctx, path); @@ -1970,7 +1970,7 @@ void pdf_update_free_text_annot_appearance(pdf_document *doc, pdf_annot *annot) } fz_always(ctx) { - fz_free_device(dev); + fz_drop_device(dev); fz_drop_display_list(ctx, dlist); font_info_fin(ctx, &font_rec); fz_drop_text(ctx, text); @@ -2193,7 +2193,7 @@ void pdf_set_signature_appearance(pdf_document *doc, pdf_annot *annot, char *nam } fz_always(ctx) { - fz_free_device(dev); + fz_drop_device(dev); fz_drop_display_list(ctx, dlist); font_info_fin(ctx, &font_rec); fz_drop_path(ctx, path); diff --git a/source/pdf/pdf-cmap-load.c b/source/pdf/pdf-cmap-load.c index 2e431215..e3bf943d 100644 --- a/source/pdf/pdf-cmap-load.c +++ b/source/pdf/pdf-cmap-load.c @@ -36,7 +36,7 @@ pdf_load_embedded_cmap(pdf_document *doc, pdf_obj *stmobj) if (pdf_obj_marked(stmobj)) fz_throw(ctx, FZ_ERROR_GENERIC, "Recursion in embedded cmap"); - if ((cmap = pdf_find_item(ctx, pdf_free_cmap_imp, stmobj)) != NULL) + if ((cmap = pdf_find_item(ctx, pdf_drop_cmap_imp, stmobj)) != NULL) { return cmap; } @@ -47,7 +47,7 @@ pdf_load_embedded_cmap(pdf_document *doc, pdf_obj *stmobj) phase = 1; cmap = pdf_load_cmap(ctx, file); phase = 2; - fz_close(file); + fz_drop_stream(file); file = NULL; wmode = pdf_dict_gets(stmobj, "WMode"); @@ -76,7 +76,7 @@ pdf_load_embedded_cmap(pdf_document *doc, pdf_obj *stmobj) fz_catch(ctx) { if (file) - fz_close(file); + fz_drop_stream(file); if (cmap) pdf_drop_cmap(ctx, cmap); if (phase < 1) diff --git a/source/pdf/pdf-cmap.c b/source/pdf/pdf-cmap.c index e9eb25b2..16167439 100644 --- a/source/pdf/pdf-cmap.c +++ b/source/pdf/pdf-cmap.c @@ -5,7 +5,7 @@ */ void -pdf_free_cmap_imp(fz_context *ctx, fz_storable *cmap_) +pdf_drop_cmap_imp(fz_context *ctx, fz_storable *cmap_) { pdf_cmap *cmap = (pdf_cmap *)cmap_; if (cmap->usecmap) @@ -20,7 +20,7 @@ pdf_cmap * pdf_new_cmap(fz_context *ctx) { pdf_cmap *cmap = fz_malloc_struct(ctx, pdf_cmap); - FZ_INIT_STORABLE(cmap, 1, pdf_free_cmap_imp); + FZ_INIT_STORABLE(cmap, 1, pdf_drop_cmap_imp); return cmap; } diff --git a/source/pdf/pdf-colorspace.c b/source/pdf/pdf-colorspace.c index 4b250f6c..50a6f9d1 100644 --- a/source/pdf/pdf-colorspace.c +++ b/source/pdf/pdf-colorspace.c @@ -84,7 +84,7 @@ rgb_to_lab(fz_context *ctx, fz_colorspace *cs, const float *rgb, float *lab) lab[2] = rgb[2]; } -static fz_colorspace k_device_lab = { {-1, fz_free_colorspace_imp}, 0, "Lab", 3, lab_to_rgb, rgb_to_lab }; +static fz_colorspace k_device_lab = { {-1, fz_drop_colorspace_imp}, 0, "Lab", 3, lab_to_rgb, rgb_to_lab }; static fz_colorspace *fz_device_lab = &k_device_lab; /* Separation and DeviceN */ @@ -219,7 +219,7 @@ load_indexed(pdf_document *doc, pdf_obj *array) } fz_always(ctx) { - fz_close(file); + fz_drop_stream(file); } fz_catch(ctx) { @@ -359,7 +359,7 @@ pdf_load_colorspace(pdf_document *doc, pdf_obj *obj) fz_context *ctx = doc->ctx; fz_colorspace *cs; - if ((cs = pdf_find_item(ctx, fz_free_colorspace_imp, obj)) != NULL) + if ((cs = pdf_find_item(ctx, fz_drop_colorspace_imp, obj)) != NULL) { return cs; } diff --git a/source/pdf/pdf-crypt.c b/source/pdf/pdf-crypt.c index d502c378..621885d0 100644 --- a/source/pdf/pdf-crypt.c +++ b/source/pdf/pdf-crypt.c @@ -58,12 +58,12 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id) obj = pdf_dict_gets(dict, "Filter"); if (!pdf_is_name(obj)) { - pdf_free_crypt(ctx, crypt); + pdf_drop_crypt(ctx, crypt); fz_throw(ctx, FZ_ERROR_GENERIC, "unspecified encryption handler"); } if (strcmp(pdf_to_name(obj), "Standard") != 0) { - pdf_free_crypt(ctx, crypt); + pdf_drop_crypt(ctx, crypt); fz_throw(ctx, FZ_ERROR_GENERIC, "unknown encryption handler: '%s'", pdf_to_name(obj)); } @@ -73,7 +73,7 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id) crypt->v = pdf_to_int(obj); if (crypt->v != 1 && crypt->v != 2 && crypt->v != 4 && crypt->v != 5) { - pdf_free_crypt(ctx, crypt); + pdf_drop_crypt(ctx, crypt); fz_throw(ctx, FZ_ERROR_GENERIC, "unknown encryption version"); } @@ -94,13 +94,13 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id) } else { - pdf_free_crypt(ctx, crypt); + pdf_drop_crypt(ctx, crypt); fz_throw(ctx, FZ_ERROR_GENERIC, "encryption dictionary missing version and revision value"); } if (crypt->r < 1 || crypt->r > 6) { int r = crypt->r; - pdf_free_crypt(ctx, crypt); + pdf_drop_crypt(ctx, crypt); fz_throw(ctx, FZ_ERROR_GENERIC, "unknown crypt revision %d", r); } @@ -112,7 +112,7 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id) memcpy(crypt->o, pdf_to_str_buf(obj), 48); else { - pdf_free_crypt(ctx, crypt); + pdf_drop_crypt(ctx, crypt); fz_throw(ctx, FZ_ERROR_GENERIC, "encryption dictionary missing owner password"); } @@ -129,7 +129,7 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id) } else { - pdf_free_crypt(ctx, crypt); + pdf_drop_crypt(ctx, crypt); fz_throw(ctx, FZ_ERROR_GENERIC, "encryption dictionary missing user password"); } @@ -147,7 +147,7 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id) obj = pdf_dict_gets(dict, "OE"); if (!pdf_is_string(obj) || pdf_to_str_len(obj) != 32) { - pdf_free_crypt(ctx, crypt); + pdf_drop_crypt(ctx, crypt); fz_throw(ctx, FZ_ERROR_GENERIC, "encryption dictionary missing owner encryption key"); } memcpy(crypt->oe, pdf_to_str_buf(obj), 32); @@ -155,7 +155,7 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id) obj = pdf_dict_gets(dict, "UE"); if (!pdf_is_string(obj) || pdf_to_str_len(obj) != 32) { - pdf_free_crypt(ctx, crypt); + pdf_drop_crypt(ctx, crypt); fz_throw(ctx, FZ_ERROR_GENERIC, "encryption dictionary missing user encryption key"); } memcpy(crypt->ue, pdf_to_str_buf(obj), 32); @@ -192,12 +192,12 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id) if (crypt->length % 8 != 0) { - pdf_free_crypt(ctx, crypt); + pdf_drop_crypt(ctx, crypt); fz_throw(ctx, FZ_ERROR_GENERIC, "invalid encryption key length"); } if (crypt->length < 40 || crypt->length > 128) { - pdf_free_crypt(ctx, crypt); + pdf_drop_crypt(ctx, crypt); fz_throw(ctx, FZ_ERROR_GENERIC, "invalid encryption key length"); } } @@ -244,7 +244,7 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id) } fz_catch(ctx) { - pdf_free_crypt(ctx, crypt); + pdf_drop_crypt(ctx, crypt); fz_rethrow_message(ctx, "cannot parse string crypt filter (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj)); } @@ -257,7 +257,7 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id) } void -pdf_free_crypt(fz_context *ctx, pdf_crypt *crypt) +pdf_drop_crypt(fz_context *ctx, pdf_crypt *crypt) { pdf_drop_obj(crypt->id); pdf_drop_obj(crypt->cf); diff --git a/source/pdf/pdf-device.c b/source/pdf/pdf-device.c index 139c4363..0d8974be 100644 --- a/source/pdf/pdf-device.c +++ b/source/pdf/pdf-device.c @@ -1238,7 +1238,7 @@ pdf_dev_end_tile(fz_device *dev) } static void -pdf_dev_free_user(fz_device *dev) +pdf_dev_drop_user(fz_device *dev) { pdf_device *pdev = dev->user; pdf_document *doc = pdev->doc; @@ -1322,7 +1322,7 @@ fz_device *pdf_new_pdf_device(pdf_document *doc, pdf_obj *contents, pdf_obj *res } dev->rebind = pdf_dev_rebind; - dev->free_user = pdf_dev_free_user; + dev->drop_user = pdf_dev_drop_user; dev->fill_path = pdf_dev_fill_path; dev->stroke_path = pdf_dev_stroke_path; diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c index 5ac722f0..a0ee8bee 100644 --- a/source/pdf/pdf-font.c +++ b/source/pdf/pdf-font.c @@ -337,7 +337,7 @@ pdf_drop_font(fz_context *ctx, pdf_font_desc *fontdesc) } static void -pdf_free_font_imp(fz_context *ctx, fz_storable *fontdesc_) +pdf_drop_font_imp(fz_context *ctx, fz_storable *fontdesc_) { pdf_font_desc *fontdesc = (pdf_font_desc *)fontdesc_; @@ -362,7 +362,7 @@ pdf_new_font_desc(fz_context *ctx) pdf_font_desc *fontdesc; fontdesc = fz_malloc_struct(ctx, pdf_font_desc); - FZ_INIT_STORABLE(fontdesc, 1, pdf_free_font_imp); + FZ_INIT_STORABLE(fontdesc, 1, pdf_drop_font_imp); fontdesc->size = sizeof(pdf_font_desc); fontdesc->font = NULL; @@ -825,7 +825,7 @@ pdf_load_hail_mary_font(pdf_document *doc) pdf_font_desc *fontdesc; pdf_font_desc *existing; - if ((fontdesc = fz_find_item(ctx, pdf_free_font_imp, &hail_mary_store_type, &hail_mary_store_type)) != NULL) + if ((fontdesc = fz_find_item(ctx, pdf_drop_font_imp, &hail_mary_store_type, &hail_mary_store_type)) != NULL) { return fontdesc; } @@ -1221,7 +1221,7 @@ pdf_load_font(pdf_document *doc, pdf_obj *rdb, pdf_obj *dict, int nested_depth) pdf_font_desc *fontdesc; int type3 = 0; - if ((fontdesc = pdf_find_item(ctx, pdf_free_font_imp, dict)) != NULL) + if ((fontdesc = pdf_find_item(ctx, pdf_drop_font_imp, dict)) != NULL) { return fontdesc; } diff --git a/source/pdf/pdf-form.c b/source/pdf/pdf-form.c index c5e2ef78..62e635ca 100644 --- a/source/pdf/pdf-form.c +++ b/source/pdf/pdf-form.c @@ -720,7 +720,7 @@ void pdf_update_page(pdf_document *doc, pdf_page *page) */ if (page->tmp_annots) { - pdf_free_annot(ctx, page->tmp_annots); + pdf_drop_annot(ctx, page->tmp_annots); page->tmp_annots = NULL; } diff --git a/source/pdf/pdf-function.c b/source/pdf/pdf-function.c index 00920732..c8986e32 100644 --- a/source/pdf/pdf-function.c +++ b/source/pdf/pdf-function.c @@ -867,7 +867,7 @@ load_postscript_func(pdf_function *func, pdf_document *doc, pdf_obj *dict, int n } fz_always(ctx) { - fz_close(stream); + fz_drop_stream(stream); pdf_lexbuf_fin(&buf); } fz_catch(ctx) @@ -1035,7 +1035,7 @@ load_sample_func(pdf_function *func, pdf_document *doc, pdf_obj *dict, int num, } fz_always(ctx) { - fz_close(stream); + fz_drop_stream(stream); } fz_catch(ctx) { @@ -1363,7 +1363,7 @@ eval_stitching_func(fz_context *ctx, pdf_function *func, float in, float *out) */ static void -pdf_free_function_imp(fz_context *ctx, fz_storable *func_) +pdf_drop_function_imp(fz_context *ctx, fz_storable *func_) { pdf_function *func = (pdf_function *)func_; int i; @@ -1637,13 +1637,13 @@ pdf_load_function(pdf_document *doc, pdf_obj *dict, int in, int out) if (pdf_obj_marked(dict)) fz_throw(ctx, FZ_ERROR_GENERIC, "Recursion in function definition"); - if ((func = pdf_find_item(ctx, pdf_free_function_imp, dict)) != NULL) + if ((func = pdf_find_item(ctx, pdf_drop_function_imp, dict)) != NULL) { return (fz_function *)func; } func = fz_malloc_struct(ctx, pdf_function); - FZ_INIT_STORABLE(&func->base, 1, pdf_free_function_imp); + FZ_INIT_STORABLE(&func->base, 1, pdf_drop_function_imp); func->base.size = sizeof(*func); func->base.evaluate = pdf_eval_function; #ifndef NDEBUG diff --git a/source/pdf/pdf-image.c b/source/pdf/pdf-image.c index ffd21dd6..dd96f4fb 100644 --- a/source/pdf/pdf-image.c +++ b/source/pdf/pdf-image.c @@ -281,7 +281,7 @@ pdf_load_image(pdf_document *doc, pdf_obj *dict) fz_context *ctx = doc->ctx; fz_image *image; - if ((image = pdf_find_item(ctx, fz_free_image, dict)) != NULL) + if ((image = pdf_find_item(ctx, fz_drop_image_imp, dict)) != NULL) { return (fz_image *)image; } diff --git a/source/pdf/pdf-interpret.c b/source/pdf/pdf-interpret.c index 359f6eda..b67de46e 100644 --- a/source/pdf/pdf-interpret.c +++ b/source/pdf/pdf-interpret.c @@ -55,7 +55,7 @@ pdf_clear_stack(pdf_csi *csi) } static void -pdf_free_csi(pdf_csi *csi) +pdf_drop_csi(pdf_csi *csi) { fz_context *ctx = csi->doc->ctx; @@ -557,7 +557,7 @@ pdf_process_annot(pdf_document *doc, pdf_page *page, pdf_annot *annot, const pdf } fz_always(ctx) { - pdf_free_csi(csi); + pdf_drop_csi(csi); } fz_catch(ctx) { @@ -581,7 +581,7 @@ pdf_process_contents_object(pdf_csi *csi, pdf_obj *rdb, pdf_obj *contents) } fz_always(ctx) { - fz_close(file); + fz_drop_stream(file); } fz_catch(ctx) { @@ -605,7 +605,7 @@ pdf_process_contents_buffer(pdf_csi *csi, pdf_obj *rdb, fz_buffer *contents) } fz_always(ctx) { - fz_close(file); + fz_drop_stream(file); } fz_catch(ctx) { @@ -626,7 +626,7 @@ pdf_process_stream_object(pdf_document *doc, pdf_obj *obj, const pdf_process *pr } fz_always(ctx) { - pdf_free_csi(csi); + pdf_drop_csi(csi); } fz_catch(ctx) { @@ -648,7 +648,7 @@ pdf_process_glyph(pdf_document *doc, pdf_obj *resources, fz_buffer *contents, pd } fz_always(ctx) { - pdf_free_csi(csi); + pdf_drop_csi(csi); } fz_catch(ctx) { diff --git a/source/pdf/pdf-object.c b/source/pdf/pdf-object.c index a3c44fe2..c3ac178a 100644 --- a/source/pdf/pdf-object.c +++ b/source/pdf/pdf-object.c @@ -1315,7 +1315,7 @@ void pdf_clean_obj(pdf_obj *obj) } static void -pdf_free_array(pdf_obj *obj) +pdf_drop_array(pdf_obj *obj) { fz_context *ctx = obj->doc->ctx; int i; @@ -1328,7 +1328,7 @@ pdf_free_array(pdf_obj *obj) } static void -pdf_free_dict(pdf_obj *obj) +pdf_drop_dict(pdf_obj *obj) { int i; fz_context *ctx = obj->doc->ctx; @@ -1350,9 +1350,9 @@ pdf_drop_obj(pdf_obj *obj) if (--obj->refs) return; if (obj->kind == PDF_ARRAY) - pdf_free_array(obj); + pdf_drop_array(obj); else if (obj->kind == PDF_DICT) - pdf_free_dict(obj); + pdf_drop_dict(obj); else fz_free(obj->doc->ctx, obj); } @@ -1402,7 +1402,7 @@ pdf_obj *pdf_new_obj_from_str(pdf_document *doc, const char *src) fz_always(ctx) { pdf_lexbuf_fin(&lexbuf); - fz_close(stream); + fz_drop_stream(stream); } fz_catch(ctx) { diff --git a/source/pdf/pdf-op-buffer.c b/source/pdf/pdf-op-buffer.c index 22436ce5..6142620c 100644 --- a/source/pdf/pdf-op-buffer.c +++ b/source/pdf/pdf-op-buffer.c @@ -790,7 +790,7 @@ free_processor_buffer(pdf_csi *csi, void *state_) pdf_buffer_state *state = (pdf_buffer_state *)state_; fz_context *ctx = state->ctx; - fz_close_output(state->out); + fz_drop_output(state->out); fz_free(ctx, state); } @@ -930,7 +930,7 @@ pdf_process *pdf_process_buffer(pdf_process *process, fz_context *ctx, fz_buffer } fz_catch(ctx) { - fz_close_output(out); + fz_drop_output(out); fz_rethrow(ctx); } diff --git a/source/pdf/pdf-outline.c b/source/pdf/pdf-outline.c index 44273dda..4e4ad642 100644 --- a/source/pdf/pdf-outline.c +++ b/source/pdf/pdf-outline.c @@ -50,7 +50,7 @@ pdf_load_outline_imp(pdf_document *doc, pdf_obj *dict) } fz_catch(ctx) { - fz_free_outline(ctx, first); + fz_drop_outline(ctx, first); fz_rethrow(ctx); } diff --git a/source/pdf/pdf-page.c b/source/pdf/pdf-page.c index 6543b7dc..cf4d1803 100644 --- a/source/pdf/pdf-page.c +++ b/source/pdf/pdf-page.c @@ -508,7 +508,7 @@ pdf_load_page(pdf_document *doc, int number) { if (fz_caught(ctx) != FZ_ERROR_TRYLATER) { - pdf_free_page(doc, page); + pdf_drop_page(doc, page); fz_rethrow_message(ctx, "cannot load page %d contents (%d 0 R)", number + 1, pdf_to_num(pageref)); } page->incomplete |= PDF_PAGE_INCOMPLETE_CONTENTS; @@ -536,7 +536,7 @@ pdf_load_links(pdf_document *doc, pdf_page *page) } void -pdf_free_page(pdf_document *doc, pdf_page *page) +pdf_drop_page(pdf_document *doc, pdf_page *page) { if (page == NULL) return; @@ -545,11 +545,11 @@ pdf_free_page(pdf_document *doc, pdf_page *page) if (page->links) fz_drop_link(doc->ctx, page->links); if (page->annots) - pdf_free_annot(doc->ctx, page->annots); + pdf_drop_annot(doc->ctx, page->annots); if (page->deleted_annots) - pdf_free_annot(doc->ctx, page->deleted_annots); + pdf_drop_annot(doc->ctx, page->deleted_annots); if (page->tmp_annots) - pdf_free_annot(doc->ctx, page->tmp_annots); + pdf_drop_annot(doc->ctx, page->tmp_annots); /* doc->focus, when not NULL, refers to one of * the annotations and must be NULLed when the * annotations are destroyed. doc->focus_obj diff --git a/source/pdf/pdf-pattern.c b/source/pdf/pdf-pattern.c index f13a49c9..785acfe5 100644 --- a/source/pdf/pdf-pattern.c +++ b/source/pdf/pdf-pattern.c @@ -13,7 +13,7 @@ pdf_drop_pattern(fz_context *ctx, pdf_pattern *pat) } static void -pdf_free_pattern_imp(fz_context *ctx, fz_storable *pat_) +pdf_drop_pattern_imp(fz_context *ctx, fz_storable *pat_) { pdf_pattern *pat = (pdf_pattern *)pat_; @@ -39,13 +39,13 @@ pdf_load_pattern(pdf_document *doc, pdf_obj *dict) pdf_obj *obj; fz_context *ctx = doc->ctx; - if ((pat = pdf_find_item(ctx, pdf_free_pattern_imp, dict)) != NULL) + if ((pat = pdf_find_item(ctx, pdf_drop_pattern_imp, dict)) != NULL) { return pat; } pat = fz_malloc_struct(ctx, pdf_pattern); - FZ_INIT_STORABLE(pat, 1, pdf_free_pattern_imp); + FZ_INIT_STORABLE(pat, 1, pdf_drop_pattern_imp); pat->resources = NULL; pat->contents = NULL; @@ -75,7 +75,7 @@ pdf_load_pattern(pdf_document *doc, pdf_obj *dict) } fz_catch(ctx) { - pdf_remove_item(ctx, pdf_free_pattern_imp, dict); + pdf_remove_item(ctx, pdf_drop_pattern_imp, dict); pdf_drop_pattern(ctx, pat); fz_rethrow_message(ctx, "cannot load pattern stream (%d %d R)", pdf_to_num(dict), pdf_to_gen(dict)); } diff --git a/source/pdf/pdf-pkcs7.c b/source/pdf/pdf-pkcs7.c index a36d1592..7af97a6d 100644 --- a/source/pdf/pdf-pkcs7.c +++ b/source/pdf/pdf-pkcs7.c @@ -357,7 +357,7 @@ struct pdf_signer_s EVP_PKEY *pkey; }; -void pdf_free_designated_name(pdf_designated_name *dn) +void pdf_drop_designated_name(pdf_designated_name *dn) { if (dn) fz_free(((pdf_designated_name_openssl *)dn)->ctx, dn); @@ -776,7 +776,7 @@ void pdf_sign_signature(pdf_document *doc, pdf_widget *widget, const char *sigfi fz_always(ctx) { pdf_drop_signer(signer); - pdf_free_designated_name(dn); + pdf_drop_designated_name(dn); fz_drop_buffer(ctx, fzbuf); } fz_catch(ctx) diff --git a/source/pdf/pdf-repair.c b/source/pdf/pdf-repair.c index 3bd3850a..3cc05fc5 100644 --- a/source/pdf/pdf-repair.c +++ b/source/pdf/pdf-repair.c @@ -225,7 +225,7 @@ pdf_repair_obj_stm(pdf_document *doc, int num, int gen) } fz_always(ctx) { - fz_close(stm); + fz_drop_stream(stm); pdf_lexbuf_fin(&buf); } fz_catch(ctx) diff --git a/source/pdf/pdf-shade.c b/source/pdf/pdf-shade.c index 40728dc7..c5009059 100644 --- a/source/pdf/pdf-shade.c +++ b/source/pdf/pdf-shade.c @@ -330,7 +330,7 @@ pdf_load_shading_dict(pdf_document *doc, pdf_obj *dict, const fz_matrix *transfo fz_try(ctx) { shade = fz_malloc_struct(ctx, fz_shade); - FZ_INIT_STORABLE(shade, 1, fz_free_shade_imp); + FZ_INIT_STORABLE(shade, 1, fz_drop_shade_imp); shade->type = FZ_MESH_TYPE4; shade->use_background = 0; shade->use_function = 0; @@ -456,7 +456,7 @@ pdf_load_shading(pdf_document *doc, pdf_obj *dict) fz_context *ctx = doc->ctx; fz_shade *shade; - if ((shade = pdf_find_item(ctx, fz_free_shade_imp, dict)) != NULL) + if ((shade = pdf_find_item(ctx, fz_drop_shade_imp, dict)) != NULL) { return shade; } diff --git a/source/pdf/pdf-store.c b/source/pdf/pdf-store.c index f8b44c44..7349e9d4 100644 --- a/source/pdf/pdf-store.c +++ b/source/pdf/pdf-store.c @@ -66,13 +66,13 @@ pdf_store_item(fz_context *ctx, pdf_obj *key, void *val, unsigned int itemsize) } void * -pdf_find_item(fz_context *ctx, fz_store_free_fn *free, pdf_obj *key) +pdf_find_item(fz_context *ctx, fz_store_drop_fn *drop, pdf_obj *key) { - return fz_find_item(ctx, free, key, &pdf_obj_store_type); + return fz_find_item(ctx, drop, key, &pdf_obj_store_type); } void -pdf_remove_item(fz_context *ctx, fz_store_free_fn *free, pdf_obj *key) +pdf_remove_item(fz_context *ctx, fz_store_drop_fn *drop, pdf_obj *key) { - fz_remove_item(ctx, free, key, &pdf_obj_store_type); + fz_remove_item(ctx, drop, key, &pdf_obj_store_type); } diff --git a/source/pdf/pdf-stream.c b/source/pdf/pdf-stream.c index f859719b..9efd1887 100644 --- a/source/pdf/pdf-stream.c +++ b/source/pdf/pdf-stream.c @@ -54,7 +54,7 @@ pdf_load_jbig2_globals(pdf_document *doc, pdf_obj *dict) fz_var(buf); - if ((globals = pdf_find_item(ctx, fz_free_jbig2_globals_imp, dict)) != NULL) + if ((globals = pdf_find_item(ctx, fz_drop_jbig2_globals_imp, dict)) != NULL) { return globals; } @@ -256,7 +256,7 @@ build_filter_chain(fz_stream *chain, pdf_document *doc, pdf_obj *fs, pdf_obj *ps } fz_catch(ctx) { - fz_close(chain); + fz_drop_stream(chain); fz_rethrow(ctx); } @@ -332,7 +332,7 @@ pdf_open_filter(fz_stream *chain, pdf_document *doc, pdf_obj *stmobj, int num, i } fz_catch(doc->ctx) { - fz_close(chain); + fz_drop_stream(chain); fz_rethrow(doc->ctx); } @@ -384,7 +384,7 @@ pdf_load_compressed_inline_image(pdf_document *doc, pdf_obj *dict, int length, f } fz_catch(ctx) { - fz_free_compressed_buffer(ctx, bc); + fz_drop_compressed_buffer(ctx, bc); fz_rethrow(ctx); } image->buffer = bc; @@ -483,7 +483,7 @@ pdf_load_raw_renumbered_stream(pdf_document *doc, int num, int gen, int orig_num buf = fz_read_all(stm, len); - fz_close(stm); + fz_drop_stream(stm); return buf; } @@ -543,7 +543,7 @@ pdf_load_image_stream(pdf_document *doc, int num, int gen, int orig_num, int ori } fz_always(ctx) { - fz_close(stm); + fz_drop_stream(stm); } fz_catch(ctx) { diff --git a/source/pdf/pdf-write.c b/source/pdf/pdf-write.c index 078719a6..32143c10 100644 --- a/source/pdf/pdf-write.c +++ b/source/pdf/pdf-write.c @@ -2553,7 +2553,7 @@ static void sanitise(pdf_document *doc) pdf_clean_page_contents(doc, page, NULL); - pdf_free_page(doc, page); + pdf_drop_page(doc, page); } } diff --git a/source/pdf/pdf-xobject.c b/source/pdf/pdf-xobject.c index c4259466..c350eb0a 100644 --- a/source/pdf/pdf-xobject.c +++ b/source/pdf/pdf-xobject.c @@ -13,7 +13,7 @@ pdf_drop_xobject(fz_context *ctx, pdf_xobject *xobj) } static void -pdf_free_xobject_imp(fz_context *ctx, fz_storable *xobj_) +pdf_drop_xobject_imp(fz_context *ctx, fz_storable *xobj_) { pdf_xobject *xobj = (pdf_xobject *)xobj_; @@ -40,13 +40,13 @@ pdf_load_xobject(pdf_document *doc, pdf_obj *dict) pdf_obj *obj; fz_context *ctx = doc->ctx; - if ((form = pdf_find_item(ctx, pdf_free_xobject_imp, dict)) != NULL) + if ((form = pdf_find_item(ctx, pdf_drop_xobject_imp, dict)) != NULL) { return form; } form = fz_malloc_struct(ctx, pdf_xobject); - FZ_INIT_STORABLE(form, 1, pdf_free_xobject_imp); + FZ_INIT_STORABLE(form, 1, pdf_drop_xobject_imp); form->resources = NULL; form->contents = NULL; form->colorspace = NULL; @@ -105,7 +105,7 @@ pdf_load_xobject(pdf_document *doc, pdf_obj *dict) } fz_catch(ctx) { - pdf_remove_item(ctx, pdf_free_xobject_imp, dict); + pdf_remove_item(ctx, pdf_drop_xobject_imp, dict); pdf_drop_xobject(ctx, form); fz_rethrow_message(ctx, "cannot load xobject content stream (%d %d R)", pdf_to_num(dict), pdf_to_gen(dict)); } @@ -182,7 +182,7 @@ pdf_new_xobject(pdf_document *doc, const fz_rect *bbox, const fz_matrix *mat) obj = NULL; form = fz_malloc_struct(ctx, pdf_xobject); - FZ_INIT_STORABLE(form, 1, pdf_free_xobject_imp); + FZ_INIT_STORABLE(form, 1, pdf_drop_xobject_imp); form->resources = NULL; form->contents = NULL; form->colorspace = NULL; diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c index 172c13e6..ef82cc2f 100644 --- a/source/pdf/pdf-xref.c +++ b/source/pdf/pdf-xref.c @@ -20,7 +20,7 @@ static inline int iswhite(int ch) * xref tables */ -static void pdf_free_xref_sections(pdf_document *doc) +static void pdf_drop_xref_sections(pdf_document *doc) { fz_context *ctx = doc->ctx; int x, e; @@ -439,7 +439,7 @@ void pdf_replace_xref(pdf_document *doc, pdf_xref_entry *entries, int n) sub = fz_malloc_struct(ctx, pdf_xref_subsec); /* The new table completely replaces the previous separate sections */ - pdf_free_xref_sections(doc); + pdf_drop_xref_sections(doc); sub->table = entries; sub->start = 0; @@ -877,7 +877,7 @@ pdf_read_new_xref(pdf_document *doc, pdf_lexbuf *buf) } fz_always(ctx) { - fz_close(stm); + fz_drop_stream(stm); } fz_catch(ctx) { @@ -1306,7 +1306,7 @@ pdf_read_ocg(pdf_document *doc) } static void -pdf_free_ocg(fz_context *ctx, pdf_ocg_descriptor *desc) +pdf_drop_ocg(fz_context *ctx, pdf_ocg_descriptor *desc) { if (!desc) return; @@ -1359,7 +1359,7 @@ pdf_init_document(pdf_document *doc) } fz_catch(ctx) { - pdf_free_xref_sections(doc); + pdf_drop_xref_sections(doc); fz_rethrow_if(ctx, FZ_ERROR_TRYLATER); fz_warn(ctx, "trying to repair broken xref"); repaired = 1; @@ -1492,15 +1492,15 @@ pdf_close_document(pdf_document *doc) if (doc->js) doc->drop_js(doc->js); - pdf_free_xref_sections(doc); + pdf_drop_xref_sections(doc); fz_free(ctx, doc->xref_index); if (doc->focus_obj) pdf_drop_obj(doc->focus_obj); if (doc->file) - fz_close(doc->file); + fz_drop_stream(doc->file); if (doc->crypt) - pdf_free_crypt(ctx, doc->crypt); + pdf_drop_crypt(ctx, doc->crypt); pdf_drop_obj(doc->linear_obj); if (doc->linear_page_refs) @@ -1531,7 +1531,7 @@ pdf_close_document(pdf_document *doc) } fz_free(ctx, doc->type3_fonts); - pdf_free_ocg(ctx, doc->ocg); + pdf_drop_ocg(ctx, doc->ocg); fz_empty_store(ctx); @@ -1659,7 +1659,7 @@ pdf_load_obj_stm(pdf_document *doc, int num, int gen, pdf_lexbuf *buf, int targe } fz_always(ctx) { - fz_close(stm); + fz_drop_stream(stm); fz_free(ctx, ofsbuf); fz_free(ctx, numbuf); pdf_drop_obj(objstm); @@ -2282,7 +2282,7 @@ pdf_new_document(fz_context *ctx, fz_stream *file) doc->super.bound_annot = (fz_document_bound_annot_fn *)pdf_bound_annot; doc->super.run_page_contents = NULL; /* see pdf_xref_aux.c */ doc->super.run_annot = NULL; /* see pdf_xref_aux.c */ - doc->super.free_page = (fz_document_free_page_fn *)pdf_free_page; + doc->super.free_page = (fz_document_free_page_fn *)pdf_drop_page; doc->super.meta = (fz_document_meta_fn *)pdf_meta; doc->super.page_presentation = (fz_document_page_presentation_fn *)pdf_page_presentation; doc->super.write = (fz_document_write_fn *)pdf_write_document; @@ -2331,7 +2331,7 @@ pdf_open_document_no_run(fz_context *ctx, const char *filename) } fz_always(ctx) { - fz_close(file); + fz_drop_stream(file); } fz_catch(ctx) { @@ -2543,7 +2543,7 @@ pdf_load_hints(pdf_document *doc, int objnum, int gennum) } fz_always(ctx) { - fz_close(stream); + fz_drop_stream(stream); } fz_catch(ctx) { diff --git a/source/tiff/mutiff.c b/source/tiff/mutiff.c index ae9a7a72..20086621 100644 --- a/source/tiff/mutiff.c +++ b/source/tiff/mutiff.c @@ -65,7 +65,7 @@ tiff_open_document(fz_context *ctx, const char *filename) } fz_always(ctx) { - fz_close(file); + fz_drop_stream(file); } fz_catch(ctx) { @@ -80,7 +80,7 @@ tiff_close_document(tiff_document *doc) { fz_context *ctx = doc->ctx; fz_drop_buffer(ctx, doc->buffer); - fz_close(doc->file); + fz_drop_stream(doc->file); fz_free(ctx, doc); } diff --git a/source/tools/mjsgen.c b/source/tools/mjsgen.c index 1987e76d..cb4c1f1c 100644 --- a/source/tools/mjsgen.c +++ b/source/tools/mjsgen.c @@ -287,7 +287,7 @@ int main(int argc, char **argv) } fclose(mujstest_file); - fz_free_context(ctx); + fz_drop_context(ctx); return 0; } diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c index 734429da..7f93d492 100644 --- a/source/tools/mudraw.c +++ b/source/tools/mudraw.c @@ -229,7 +229,7 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) } fz_always(ctx) { - fz_free_device(dev); + fz_drop_device(dev); dev = NULL; } fz_catch(ctx) @@ -252,7 +252,7 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) } fz_always(ctx) { - fz_free_device(dev); + fz_drop_device(dev); dev = NULL; } fz_catch(ctx) @@ -279,7 +279,7 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) fz_run_display_list(list, dev, &fz_identity, &fz_infinite_rect, &cookie); else fz_run_page(doc, page, dev, &fz_identity, &cookie); - fz_free_device(dev); + fz_drop_device(dev); dev = NULL; if (showtext == TEXT_XML) { @@ -298,9 +298,9 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) } fz_always(ctx) { - fz_free_device(dev); + fz_drop_device(dev); dev = NULL; - fz_free_text_page(ctx, text); + fz_drop_text_page(ctx, text); } fz_catch(ctx) { @@ -326,7 +326,7 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) } fz_always(ctx) { - fz_free_device(dev); + fz_drop_device(dev); dev = NULL; } fz_catch(ctx) @@ -356,12 +356,12 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) fz_run_display_list(list, dev, &ctm, &tbounds, &cookie); else fz_run_page(doc, page, dev, &ctm, &cookie); - fz_free_device(dev); + fz_drop_device(dev); dev = NULL; } fz_always(ctx) { - fz_free_device(dev); + fz_drop_device(dev); dev = NULL; } fz_catch(ctx) @@ -371,7 +371,7 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) fz_rethrow(ctx); } pdf_insert_page(pdfout, newpage, INT_MAX); - pdf_free_page(pdfout, newpage); + pdf_drop_page(pdfout, newpage); } if (output && output_format == OUT_SVG) @@ -408,14 +408,14 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) fz_run_display_list(list, dev, &ctm, &tbounds, &cookie); else fz_run_page(doc, page, dev, &ctm, &cookie); - fz_free_device(dev); + fz_drop_device(dev); dev = NULL; } fz_always(ctx) { - fz_free_device(dev); + fz_drop_device(dev); dev = NULL; - fz_close_output(out); + fz_drop_output(out); if (file != stdout) fclose(file); } @@ -556,7 +556,7 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) fz_run_display_list(list, dev, &ctm, &tbounds, &cookie); else fz_run_page(doc, page, dev, &ctm, &cookie); - fz_free_device(dev); + fz_drop_device(dev); dev = NULL; if (invert) @@ -639,11 +639,11 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) fz_output_png_trailer(output_file, poc); } - fz_free_device(dev); + fz_drop_device(dev); dev = NULL; fz_drop_pixmap(ctx, pix); if (output_file) - fz_close_output(output_file); + fz_drop_output(output_file); } fz_catch(ctx) { @@ -749,8 +749,8 @@ static void drawoutline(fz_context *ctx, fz_document *doc) } fz_always(ctx) { - fz_close_output(out); - fz_free_outline(ctx, outline); + fz_drop_output(out); + fz_drop_outline(ctx, outline); } fz_catch(ctx) { @@ -1105,11 +1105,11 @@ int main(int argc, char **argv) } if (showtext) - fz_free_text_sheet(ctx, sheet); + fz_drop_text_sheet(ctx, sheet); if (showxml || showtext) { - fz_close_output(out); + fz_drop_output(out); out = NULL; } @@ -1131,7 +1131,7 @@ int main(int argc, char **argv) } } - fz_free_context(ctx); + fz_drop_context(ctx); if (showmemory) { diff --git a/source/tools/pdfclean.c b/source/tools/pdfclean.c index d7d5ac97..bfeca0e4 100644 --- a/source/tools/pdfclean.c +++ b/source/tools/pdfclean.c @@ -310,7 +310,7 @@ int pdfclean_main(int argc, char **argv) { errors++; } - fz_free_context(ctx); + fz_drop_context(ctx); return errors == 0; } diff --git a/source/tools/pdfextract.c b/source/tools/pdfextract.c index b9697985..0c7463f7 100644 --- a/source/tools/pdfextract.c +++ b/source/tools/pdfextract.c @@ -233,6 +233,6 @@ int pdfextract_main(int argc, char **argv) pdf_close_document(doc); fz_flush_warnings(ctx); - fz_free_context(ctx); + fz_drop_context(ctx); return 0; } diff --git a/source/tools/pdfinfo.c b/source/tools/pdfinfo.c index ff05012f..453f271a 100644 --- a/source/tools/pdfinfo.c +++ b/source/tools/pdfinfo.c @@ -1071,7 +1071,7 @@ int pdfinfo_main(int argc, char **argv) { ret = 1; } - fz_close_output(out); - fz_free_context(ctx); + fz_drop_output(out); + fz_drop_context(ctx); return ret; } diff --git a/source/tools/pdfposter.c b/source/tools/pdfposter.c index aedeccb4..e4b631a6 100644 --- a/source/tools/pdfposter.c +++ b/source/tools/pdfposter.c @@ -169,6 +169,6 @@ int pdfposter_main(int argc, char **argv) pdf_write_document(doc, outfile, &opts); pdf_close_document(doc); - fz_free_context(ctx); + fz_drop_context(ctx); return 0; } diff --git a/source/tools/pdfshow.c b/source/tools/pdfshow.c index c5d021ad..344f4c40 100644 --- a/source/tools/pdfshow.c +++ b/source/tools/pdfshow.c @@ -118,7 +118,7 @@ static void showstream(int num, int gen) showsafe(buf, n); } - fz_close(stm); + fz_drop_stream(stm); } static void showobject(int num, int gen) @@ -265,6 +265,6 @@ int pdfshow_main(int argc, char **argv) fclose(out); pdf_close_document(doc); - fz_free_context(ctx); + fz_drop_context(ctx); return 0; } diff --git a/source/xps/xps-doc.c b/source/xps/xps-doc.c index 4bcf92cb..2b8cee8e 100644 --- a/source/xps/xps-doc.c +++ b/source/xps/xps-doc.c @@ -218,7 +218,7 @@ xps_lookup_link_target(xps_document *doc, char *target_uri) } static void -xps_free_link_targets(xps_document *doc) +xps_drop_link_targets(xps_document *doc) { xps_target *target = doc->target, *next; while (target) @@ -231,13 +231,13 @@ xps_free_link_targets(xps_document *doc) } static void -xps_free_fixed_pages(xps_document *doc) +xps_drop_fixed_pages(xps_document *doc) { xps_page *page = doc->first_page; while (page) { xps_page *next = page->next; - xps_free_page(doc, page); + xps_drop_page(doc, page); fz_drop_link(doc->ctx, page->links); fz_free(doc->ctx, page->name); fz_free(doc->ctx, page); @@ -248,7 +248,7 @@ xps_free_fixed_pages(xps_document *doc) } static void -xps_free_fixed_documents(xps_document *doc) +xps_drop_fixed_documents(xps_document *doc) { xps_fixdoc *fixdoc = doc->first_fixdoc; while (fixdoc) @@ -264,11 +264,11 @@ xps_free_fixed_documents(xps_document *doc) } void -xps_free_page_list(xps_document *doc) +xps_drop_page_list(xps_document *doc) { - xps_free_fixed_documents(doc); - xps_free_fixed_pages(doc); - xps_free_link_targets(doc); + xps_drop_fixed_documents(doc); + xps_drop_fixed_pages(doc); + xps_drop_link_targets(doc); } /* @@ -362,7 +362,7 @@ xps_parse_metadata(xps_document *doc, xps_part *part, xps_fixdoc *fixdoc) root = fz_parse_xml(doc->ctx, part->data, part->size, 0); xps_parse_metadata_imp(doc, root, fixdoc); - fz_free_xml(doc->ctx, root); + fz_drop_xml(doc->ctx, root); doc->base_uri = NULL; doc->part_uri = NULL; @@ -384,7 +384,7 @@ xps_read_and_process_metadata_part(xps_document *doc, char *name, xps_fixdoc *fi } fz_always(ctx) { - xps_free_part(doc, part); + xps_drop_part(doc, part); } fz_catch(ctx) { @@ -443,7 +443,7 @@ xps_load_fixed_page(xps_document *doc, xps_page *page) } fz_always(ctx) { - xps_free_part(doc, part); + xps_drop_part(doc, part); } fz_catch(ctx) { @@ -458,31 +458,31 @@ xps_load_fixed_page(xps_document *doc, xps_page *page) fz_xml *node = xps_lookup_alternate_content(root); if (!node) { - fz_free_xml(doc->ctx, root); + fz_drop_xml(doc->ctx, root); fz_throw(doc->ctx, FZ_ERROR_GENERIC, "FixedPage missing alternate root element"); } fz_detach_xml(node); - fz_free_xml(doc->ctx, root); + fz_drop_xml(doc->ctx, root); root = node; } if (strcmp(fz_xml_tag(root), "FixedPage")) { - fz_free_xml(doc->ctx, root); + fz_drop_xml(doc->ctx, root); fz_throw(doc->ctx, FZ_ERROR_GENERIC, "expected FixedPage element"); } width_att = fz_xml_att(root, "Width"); if (!width_att) { - fz_free_xml(doc->ctx, root); + fz_drop_xml(doc->ctx, root); fz_throw(doc->ctx, FZ_ERROR_GENERIC, "FixedPage missing required attribute: Width"); } height_att = fz_xml_att(root, "Height"); if (!height_att) { - fz_free_xml(doc->ctx, root); + fz_drop_xml(doc->ctx, root); fz_throw(doc->ctx, FZ_ERROR_GENERIC, "FixedPage missing required attribute: Height"); } @@ -522,13 +522,13 @@ xps_bound_page(xps_document *doc, xps_page *page, fz_rect *bounds) } void -xps_free_page(xps_document *doc, xps_page *page) +xps_drop_page(xps_document *doc, xps_page *page) { if (page == NULL) return; /* only free the XML contents */ if (page->root) - fz_free_xml(doc->ctx, page->root); + fz_drop_xml(doc->ctx, page->root); page->root = NULL; } diff --git a/source/xps/xps-glyphs.c b/source/xps/xps-glyphs.c index d2a786fe..4f030be0 100644 --- a/source/xps/xps-glyphs.c +++ b/source/xps/xps-glyphs.c @@ -539,7 +539,7 @@ xps_parse_glyphs(xps_document *doc, const fz_matrix *ctm, fz_always(doc->ctx) { fz_drop_buffer(doc->ctx, buf); - xps_free_part(doc, part); + xps_drop_part(doc, part); } fz_catch(doc->ctx) { diff --git a/source/xps/xps-gradient.c b/source/xps/xps-gradient.c index 4c1d0851..d156a406 100644 --- a/source/xps/xps-gradient.c +++ b/source/xps/xps-gradient.c @@ -214,7 +214,7 @@ xps_draw_one_radial_gradient(xps_document *doc, const fz_matrix *ctm, /* TODO: this (and the stuff in pdf_shade) should move to res_shade.c */ shade = fz_malloc_struct(doc->ctx, fz_shade); - FZ_INIT_STORABLE(shade, 1, fz_free_shade_imp); + FZ_INIT_STORABLE(shade, 1, fz_drop_shade_imp); shade->colorspace = fz_device_rgb(doc->ctx); shade->bbox = fz_infinite_rect; shade->matrix = fz_identity; @@ -252,7 +252,7 @@ xps_draw_one_linear_gradient(xps_document *doc, const fz_matrix *ctm, /* TODO: this (and the stuff in pdf_shade) should move to res_shade.c */ shade = fz_malloc_struct(doc->ctx, fz_shade); - FZ_INIT_STORABLE(shade, 1, fz_free_shade_imp); + FZ_INIT_STORABLE(shade, 1, fz_drop_shade_imp); shade->colorspace = fz_device_rgb(doc->ctx); shade->bbox = fz_infinite_rect; shade->matrix = fz_identity; diff --git a/source/xps/xps-image.c b/source/xps/xps-image.c index 9b2aefcb..d9b2ad11 100644 --- a/source/xps/xps-image.c +++ b/source/xps/xps-image.c @@ -114,7 +114,7 @@ xps_parse_image_brush(xps_document *doc, const fz_matrix *ctm, const fz_rect *ar } fz_always(doc->ctx) { - xps_free_part(doc, part); + xps_drop_part(doc, part); } fz_catch(doc->ctx) { diff --git a/source/xps/xps-outline.c b/source/xps/xps-outline.c index e314e83e..3b088d78 100644 --- a/source/xps/xps-outline.c +++ b/source/xps/xps-outline.c @@ -90,7 +90,7 @@ xps_load_document_structure(xps_document *doc, xps_fixdoc *fixdoc) } fz_always(doc->ctx) { - xps_free_part(doc, part); + xps_drop_part(doc, part); } fz_catch(doc->ctx) { @@ -105,7 +105,7 @@ xps_load_document_structure(xps_document *doc, xps_fixdoc *fixdoc) } fz_always(doc->ctx) { - fz_free_xml(doc->ctx, root); + fz_drop_xml(doc->ctx, root); } fz_catch(doc->ctx) { diff --git a/source/xps/xps-resource.c b/source/xps/xps-resource.c index 85fd7c49..6600f7c6 100644 --- a/source/xps/xps-resource.c +++ b/source/xps/xps-resource.c @@ -71,7 +71,7 @@ xps_parse_remote_resource_dictionary(xps_document *doc, char *base_uri, char *so } fz_always(ctx) { - xps_free_part(doc, part); + xps_drop_part(doc, part); } fz_catch(ctx) { @@ -84,7 +84,7 @@ xps_parse_remote_resource_dictionary(xps_document *doc, char *base_uri, char *so if (strcmp(fz_xml_tag(xml), "ResourceDictionary")) { - fz_free_xml(doc->ctx, xml); + fz_drop_xml(doc->ctx, xml); fz_throw(doc->ctx, FZ_ERROR_GENERIC, "expected ResourceDictionary element"); } @@ -138,14 +138,14 @@ xps_parse_resource_dictionary(xps_document *doc, char *base_uri, fz_xml *root) } void -xps_free_resource_dictionary(xps_document *doc, xps_resource *dict) +xps_drop_resource_dictionary(xps_document *doc, xps_resource *dict) { xps_resource *next; while (dict) { next = dict->next; if (dict->base_xml) - fz_free_xml(doc->ctx, dict->base_xml); + fz_drop_xml(doc->ctx, dict->base_xml); if (dict->base_uri) fz_free(doc->ctx, dict->base_uri); fz_free(doc->ctx, dict); diff --git a/source/xps/xps-tile.c b/source/xps/xps-tile.c index 5f966619..b7e0ec19 100644 --- a/source/xps/xps-tile.c +++ b/source/xps/xps-tile.c @@ -329,7 +329,7 @@ xps_parse_canvas(xps_document *doc, const fz_matrix *ctm, const fz_rect *area, c fz_pop_clip(doc->dev); if (new_dict) - xps_free_resource_dictionary(doc, new_dict); + xps_drop_resource_dictionary(doc, new_dict); } void @@ -371,7 +371,7 @@ xps_parse_fixed_page(xps_document *doc, const fz_matrix *ctm, xps_page *page) } if (dict) - xps_free_resource_dictionary(doc, dict); + xps_drop_resource_dictionary(doc, dict); } void diff --git a/source/xps/xps-zip.c b/source/xps/xps-zip.c index 1dbd103c..a8f25114 100644 --- a/source/xps/xps-zip.c +++ b/source/xps/xps-zip.c @@ -26,7 +26,7 @@ xps_new_part(xps_document *doc, char *name, unsigned char *data, int size) } void -xps_free_part(xps_document *doc, xps_part *part) +xps_drop_part(xps_document *doc, xps_part *part) { fz_free(doc->ctx, part->name); fz_free(doc->ctx, part->data); @@ -194,7 +194,7 @@ xps_open_document(fz_context *ctx, const char *filename) } fz_always(ctx) { - fz_close(file); + fz_drop_stream(file); } fz_catch(ctx) { @@ -212,7 +212,7 @@ xps_close_document(xps_document *doc) return; if (doc->zip) - fz_close_archive(doc->ctx, doc->zip); + fz_drop_archive(doc->ctx, doc->zip); font = doc->font_table; while (font) @@ -224,7 +224,7 @@ xps_close_document(xps_document *doc) font = next; } - xps_free_page_list(doc); + xps_drop_page_list(doc); fz_free(doc->ctx, doc->start_part); fz_free(doc->ctx, doc); @@ -262,7 +262,7 @@ xps_init_document(xps_document *doc) doc->super.load_links = (fz_document_load_links_fn *)xps_load_links; doc->super.bound_page = (fz_document_bound_page_fn *)xps_bound_page; doc->super.run_page_contents = (fz_document_run_page_contents_fn *)xps_run_page; - doc->super.free_page = (fz_document_free_page_fn *)xps_free_page; + doc->super.free_page = (fz_document_free_page_fn *)xps_drop_page; doc->super.meta = (fz_document_meta_fn *)xps_meta; doc->super.rebind = (fz_document_rebind_fn *)xps_rebind; } -- cgit v1.2.3