summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/fitz/colorspace.c6
-rw-r--r--source/fitz/filter-jbig2.c9
-rw-r--r--source/fitz/font.c6
-rw-r--r--source/fitz/halftone.c9
-rw-r--r--source/fitz/image.c4
-rw-r--r--source/fitz/load-jxr.c6
-rw-r--r--source/fitz/pixmap.c6
-rw-r--r--source/fitz/shade.c3
-rw-r--r--source/fitz/stream-open.c3
-rw-r--r--source/pdf/pdf-annot.c3
-rw-r--r--source/pdf/pdf-cmap.c6
-rw-r--r--source/pdf/pdf-font.c12
-rw-r--r--source/pdf/pdf-js.c3
-rw-r--r--source/pdf/pdf-op-run.c39
-rw-r--r--source/pdf/pdf-page.c6
-rw-r--r--source/pdf/pdf-pattern.c6
-rw-r--r--source/pdf/pdf-pkcs7.c3
-rw-r--r--source/pdf/pdf-shade.c3
-rw-r--r--source/pdf/pdf-type3.c3
-rw-r--r--source/pdf/pdf-xref.c18
-rw-r--r--source/tools/mudraw.c3
-rw-r--r--source/xps/xps-resource.c6
22 files changed, 54 insertions, 109 deletions
diff --git a/source/fitz/colorspace.c b/source/fitz/colorspace.c
index 84e9b36c..0842c7f1 100644
--- a/source/fitz/colorspace.c
+++ b/source/fitz/colorspace.c
@@ -1996,8 +1996,7 @@ static void
free_indexed(fz_context *ctx, fz_colorspace *cs)
{
struct indexed *idx = cs->data;
- if (idx->base)
- fz_drop_colorspace(ctx, idx->base);
+ fz_drop_colorspace(ctx, idx->base);
fz_free(ctx, idx->lookup);
fz_free(ctx, idx);
}
@@ -2167,8 +2166,7 @@ void fz_fin_cached_color_converter(fz_context *ctx, fz_color_converter *cc_)
for (i = 0; i < n; i++)
{
void *v = fz_hash_get_val(ctx, cc->hash, i);
- if (v)
- fz_free(ctx, v);
+ fz_free(ctx, v);
}
fz_drop_hash(ctx, cc->hash);
fz_free(ctx, cc);
diff --git a/source/fitz/filter-jbig2.c b/source/fitz/filter-jbig2.c
index de5379be..b0445ed9 100644
--- a/source/fitz/filter-jbig2.c
+++ b/source/fitz/filter-jbig2.c
@@ -37,8 +37,7 @@ close_jbig2d(fz_context *ctx, void *state_)
{
fz_jbig2d *state = state_;
fz_free(ctx, state->output);
- if (state->gctx)
- fz_drop_jbig2_globals(ctx, state->gctx);
+ fz_drop_jbig2_globals(ctx, state->gctx);
fz_drop_stream(ctx, state->chain);
fz_free(ctx, state);
}
@@ -234,8 +233,7 @@ fz_open_jbig2d(fz_context *ctx, fz_stream *chain, fz_jbig2_globals *globals)
}
fz_catch(ctx)
{
- if (state)
- fz_drop_jbig2_globals(ctx, state->gctx);
+ fz_drop_jbig2_globals(ctx, globals);
fz_free(ctx, state);
fz_drop_stream(ctx, chain);
fz_rethrow(ctx);
@@ -278,8 +276,7 @@ close_jbig2d(fz_context *ctx, void *state_)
fz_jbig2d *state = state_;
if (state->page)
jbig2_release_page(state->ctx, state->page);
- if (state->gctx)
- fz_drop_jbig2_globals(ctx, state->gctx);
+ fz_drop_jbig2_globals(ctx, state->gctx);
jbig2_ctx_free(state->ctx);
fz_drop_stream(ctx, state->chain);
fz_free(ctx, state);
diff --git a/source/fitz/font.c b/source/fitz/font.c
index 346168e8..e3ae4d7d 100644
--- a/source/fitz/font.c
+++ b/source/fitz/font.c
@@ -101,8 +101,7 @@ free_resources(fz_context *ctx, fz_font *font)
if (font->t3procs)
{
for (i = 0; i < 256; i++)
- if (font->t3procs[i])
- fz_drop_buffer(ctx, font->t3procs[i]);
+ fz_drop_buffer(ctx, font->t3procs[i]);
}
fz_free(ctx, font->t3procs);
font->t3procs = NULL;
@@ -133,8 +132,7 @@ fz_drop_font(fz_context *ctx, fz_font *font)
{
free_resources(ctx, font);
for (i = 0; i < 256; i++)
- if (font->t3lists[i])
- fz_drop_display_list(ctx, font->t3lists[i]);
+ fz_drop_display_list(ctx, font->t3lists[i]);
fz_free(ctx, font->t3procs);
fz_free(ctx, font->t3lists);
fz_free(ctx, font->t3widths);
diff --git a/source/fitz/halftone.c b/source/fitz/halftone.c
index 0bc1dc98..dd9bb58f 100644
--- a/source/fitz/halftone.c
+++ b/source/fitz/halftone.c
@@ -515,7 +515,7 @@ fz_bitmap *fz_new_bitmap_from_pixmap_band(fz_context *ctx, fz_pixmap *pix, fz_ha
unsigned char *ht_line = NULL;
unsigned char *o, *p;
int w, h, x, y, n, pstride, ostride, lcm, i;
- fz_halftone *ht_orig = ht;
+ fz_halftone *ht_ = NULL;
threshold_fn *thresh;
if (!pix)
@@ -542,9 +542,7 @@ fz_bitmap *fz_new_bitmap_from_pixmap_band(fz_context *ctx, fz_pixmap *pix, fz_ha
}
if (ht == NULL)
- {
- ht = fz_default_halftone(ctx, n);
- }
+ ht_ = ht = fz_default_halftone(ctx, n);
/* Find the minimum length for the halftone line. This
* is the LCM of the halftone lengths and 8. (We need a
@@ -583,8 +581,7 @@ fz_bitmap *fz_new_bitmap_from_pixmap_band(fz_context *ctx, fz_pixmap *pix, fz_ha
}
fz_always(ctx)
{
- if (!ht_orig)
- fz_drop_halftone(ctx, ht);
+ fz_drop_halftone(ctx, ht_);
fz_free(ctx, ht_line);
}
fz_catch(ctx)
diff --git a/source/fitz/image.c b/source/fitz/image.c
index 3420067d..48420a81 100644
--- a/source/fitz/image.c
+++ b/source/fitz/image.c
@@ -357,10 +357,8 @@ fz_decomp_image_from_stream(fz_context *ctx, fz_stream *stm, fz_compressed_image
}
fz_catch(ctx)
{
- if (tile)
- fz_drop_pixmap(ctx, tile);
+ fz_drop_pixmap(ctx, tile);
fz_free(ctx, samples);
-
fz_rethrow(ctx);
}
diff --git a/source/fitz/load-jxr.c b/source/fitz/load-jxr.c
index 3742b49e..f3809e69 100644
--- a/source/fitz/load-jxr.c
+++ b/source/fitz/load-jxr.c
@@ -422,10 +422,8 @@ fz_load_jxr(fz_context *ctx, unsigned char *data, size_t size)
}
fz_always(ctx)
{
- if (info.samples)
- fz_free(ctx, info.samples);
- if (info.cspace)
- fz_drop_colorspace(ctx, info.cspace);
+ fz_free(ctx, info.samples);
+ fz_drop_colorspace(ctx, info.cspace);
}
fz_catch(ctx)
{
diff --git a/source/fitz/pixmap.c b/source/fitz/pixmap.c
index 6ebc4770..c5a8a8cc 100644
--- a/source/fitz/pixmap.c
+++ b/source/fitz/pixmap.c
@@ -17,8 +17,7 @@ fz_drop_pixmap_imp(fz_context *ctx, fz_storable *pix_)
{
fz_pixmap *pix = (fz_pixmap *)pix_;
- if (pix->colorspace)
- fz_drop_colorspace(ctx, pix->colorspace);
+ fz_drop_colorspace(ctx, pix->colorspace);
if (pix->free_samples)
fz_free(ctx, pix->samples);
fz_free(ctx, pix);
@@ -77,8 +76,7 @@ fz_new_pixmap_with_data(fz_context *ctx, fz_colorspace *colorspace, int w, int h
}
fz_catch(ctx)
{
- if (colorspace)
- fz_drop_colorspace(ctx, colorspace);
+ fz_drop_colorspace(ctx, colorspace);
fz_free(ctx, pix);
fz_rethrow(ctx);
}
diff --git a/source/fitz/shade.c b/source/fitz/shade.c
index b4f4b0c7..274d40f3 100644
--- a/source/fitz/shade.c
+++ b/source/fitz/shade.c
@@ -1056,8 +1056,7 @@ fz_drop_shade_imp(fz_context *ctx, fz_storable *shade_)
{
fz_shade *shade = (fz_shade *)shade_;
- if (shade->colorspace)
- fz_drop_colorspace(ctx, shade->colorspace);
+ fz_drop_colorspace(ctx, shade->colorspace);
if (shade->type == FZ_FUNCTION_BASED)
fz_free(ctx, shade->u.f.fn_vals);
fz_drop_compressed_buffer(ctx, shade->buffer);
diff --git a/source/fitz/stream-open.c b/source/fitz/stream-open.c
index 05cbc48a..cb80b4f3 100644
--- a/source/fitz/stream-open.c
+++ b/source/fitz/stream-open.c
@@ -191,8 +191,7 @@ static void seek_buffer(fz_context *ctx, fz_stream *stm, fz_off_t offset, int wh
static void close_buffer(fz_context *ctx, void *state_)
{
fz_buffer *state = (fz_buffer *)state_;
- if (state)
- fz_drop_buffer(ctx, state);
+ fz_drop_buffer(ctx, state);
}
fz_stream *
diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c
index ff878a17..a0220099 100644
--- a/source/pdf/pdf-annot.c
+++ b/source/pdf/pdf-annot.c
@@ -386,8 +386,7 @@ pdf_load_link_annots(fz_context *ctx, pdf_document *doc, pdf_obj *annots, const
static void
pdf_drop_annot_imp(fz_context *ctx, pdf_annot *annot)
{
- if (annot->ap)
- pdf_drop_xobject(ctx, annot->ap);
+ pdf_drop_xobject(ctx, annot->ap);
pdf_drop_obj(ctx, annot->obj);
}
diff --git a/source/pdf/pdf-cmap.c b/source/pdf/pdf-cmap.c
index 14652c8a..7238fb42 100644
--- a/source/pdf/pdf-cmap.c
+++ b/source/pdf/pdf-cmap.c
@@ -8,8 +8,7 @@ void
pdf_drop_cmap_imp(fz_context *ctx, fz_storable *cmap_)
{
pdf_cmap *cmap = (pdf_cmap *)cmap_;
- if (cmap->usecmap)
- pdf_drop_cmap(ctx, cmap->usecmap);
+ pdf_drop_cmap(ctx, cmap->usecmap);
fz_free(ctx, cmap->ranges);
fz_free(ctx, cmap->xranges);
fz_free(ctx, cmap->mranges);
@@ -43,8 +42,7 @@ pdf_set_usecmap(fz_context *ctx, pdf_cmap *cmap, pdf_cmap *usecmap)
{
int i;
- if (cmap->usecmap)
- pdf_drop_cmap(ctx, cmap->usecmap);
+ pdf_drop_cmap(ctx, cmap->usecmap);
cmap->usecmap = pdf_keep_cmap(ctx, usecmap);
if (cmap->codespace_len == 0)
diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c
index aaab41a5..133462d6 100644
--- a/source/pdf/pdf-font.c
+++ b/source/pdf/pdf-font.c
@@ -473,14 +473,10 @@ pdf_drop_font_imp(fz_context *ctx, fz_storable *fontdesc_)
{
pdf_font_desc *fontdesc = (pdf_font_desc *)fontdesc_;
- if (fontdesc->font)
- fz_drop_font(ctx, fontdesc->font);
- if (fontdesc->encoding)
- pdf_drop_cmap(ctx, fontdesc->encoding);
- if (fontdesc->to_ttf_cmap)
- pdf_drop_cmap(ctx, fontdesc->to_ttf_cmap);
- if (fontdesc->to_unicode)
- pdf_drop_cmap(ctx, fontdesc->to_unicode);
+ fz_drop_font(ctx, fontdesc->font);
+ pdf_drop_cmap(ctx, fontdesc->encoding);
+ pdf_drop_cmap(ctx, fontdesc->to_ttf_cmap);
+ pdf_drop_cmap(ctx, fontdesc->to_unicode);
fz_free(ctx, fontdesc->cid_to_gid);
fz_free(ctx, fontdesc->cid_to_ucs);
fz_free(ctx, fontdesc->hmtx);
diff --git a/source/pdf/pdf-js.c b/source/pdf/pdf-js.c
index 4fc6dc98..f3a2ca80 100644
--- a/source/pdf/pdf-js.c
+++ b/source/pdf/pdf-js.c
@@ -710,8 +710,7 @@ void pdf_enable_js(fz_context *ctx, pdf_document *doc)
void pdf_disable_js(fz_context *ctx, pdf_document *doc)
{
- if (doc->js)
- pdf_drop_js(ctx, doc->js);
+ pdf_drop_js(ctx, doc->js);
doc->js = NULL;
}
diff --git a/source/pdf/pdf-op-run.c b/source/pdf/pdf-op-run.c
index bfee0866..89bbf008 100644
--- a/source/pdf/pdf-op-run.c
+++ b/source/pdf/pdf-op-run.c
@@ -240,12 +240,9 @@ pdf_keep_material(fz_context *ctx, pdf_material *mat)
static pdf_material *
pdf_drop_material(fz_context *ctx, pdf_material *mat)
{
- if (mat->colorspace)
- fz_drop_colorspace(ctx, mat->colorspace);
- if (mat->pattern)
- pdf_drop_pattern(ctx, mat->pattern);
- if (mat->shade)
- fz_drop_shade(ctx, mat->shade);
+ fz_drop_colorspace(ctx, mat->colorspace);
+ pdf_drop_pattern(ctx, mat->pattern);
+ fz_drop_shade(ctx, mat->shade);
return mat;
}
@@ -272,8 +269,7 @@ pdf_unset_pattern(fz_context *ctx, pdf_run_processor *pr, int what)
mat = what == PDF_FILL ? &gs->fill : &gs->stroke;
if (mat->kind == PDF_MAT_PATTERN)
{
- if (mat->pattern)
- pdf_drop_pattern(ctx, mat->pattern);
+ pdf_drop_pattern(ctx, mat->pattern);
mat->pattern = NULL;
mat->kind = PDF_MAT_COLOR;
}
@@ -298,12 +294,9 @@ pdf_drop_gstate(fz_context *ctx, pdf_gstate *gs)
{
pdf_drop_material(ctx, &gs->stroke);
pdf_drop_material(ctx, &gs->fill);
- if (gs->font)
- pdf_drop_font(ctx, gs->font);
- if (gs->softmask)
- pdf_drop_xobject(ctx, gs->softmask);
- if (gs->softmask_resources)
- pdf_drop_obj(ctx, gs->softmask_resources);
+ pdf_drop_font(ctx, gs->font);
+ pdf_drop_xobject(ctx, gs->softmask);
+ pdf_drop_obj(ctx, gs->softmask_resources);
fz_drop_stroke_state(ctx, gs->stroke_state);
}
@@ -1184,8 +1177,7 @@ pdf_set_shade(fz_context *ctx, pdf_run_processor *pr, int what, fz_shade *shade)
mat = what == PDF_FILL ? &gs->fill : &gs->stroke;
- if (mat->shade)
- fz_drop_shade(ctx, mat->shade);
+ fz_drop_shade(ctx, mat->shade);
mat->kind = PDF_MAT_SHADE;
mat->shade = fz_keep_shade(ctx, shade);
@@ -1203,14 +1195,12 @@ pdf_set_pattern(fz_context *ctx, pdf_run_processor *pr, int what, pdf_pattern *p
mat = what == PDF_FILL ? &gs->fill : &gs->stroke;
- if (mat->pattern)
- pdf_drop_pattern(ctx, mat->pattern);
+ pdf_drop_pattern(ctx, mat->pattern);
+ mat->pattern = NULL;
mat->kind = PDF_MAT_PATTERN;
if (pat)
mat->pattern = pdf_keep_pattern(ctx, pat);
- else
- mat->pattern = NULL;
if (v)
pdf_set_color(ctx, pr, what, v);
@@ -1701,8 +1691,7 @@ static void pdf_run_Tf(fz_context *ctx, pdf_processor *proc, const char *name, p
{
pdf_run_processor *pr = (pdf_run_processor *)proc;
pdf_gstate *gstate = pr->gstate + pr->gtop;
- if (gstate->font)
- pdf_drop_font(ctx, gstate->font);
+ pdf_drop_font(ctx, gstate->font);
gstate->font = pdf_keep_font(ctx, font);
gstate->size = size;
}
@@ -2015,10 +2004,8 @@ pdf_drop_run_processor(fz_context *ctx, pdf_processor *proc)
pdf_drop_material(ctx, &pr->gstate[0].fill);
pdf_drop_material(ctx, &pr->gstate[0].stroke);
- if (pr->gstate[0].font)
- pdf_drop_font(ctx, pr->gstate[0].font);
- if (pr->gstate[0].softmask)
- pdf_drop_xobject(ctx, pr->gstate[0].softmask);
+ pdf_drop_font(ctx, pr->gstate[0].font);
+ pdf_drop_xobject(ctx, pr->gstate[0].softmask);
fz_drop_stroke_state(ctx, pr->gstate[0].stroke_state);
while (pr->gstate[0].clip_depth--)
diff --git a/source/pdf/pdf-page.c b/source/pdf/pdf-page.c
index 73d01480..f0e45402 100644
--- a/source/pdf/pdf-page.c
+++ b/source/pdf/pdf-page.c
@@ -507,10 +507,8 @@ pdf_drop_page_imp(fz_context *ctx, pdf_page *page)
if (page == NULL)
return;
- if (page->links)
- fz_drop_link(ctx, page->links);
- if (page->annots)
- pdf_drop_annots(ctx, page->annots);
+ fz_drop_link(ctx, page->links);
+ pdf_drop_annots(ctx, page->annots);
/* doc->focus, when not NULL, refers to one of
* the annotations and must be NULLed when the
diff --git a/source/pdf/pdf-pattern.c b/source/pdf/pdf-pattern.c
index 0e4910f3..2091f400 100644
--- a/source/pdf/pdf-pattern.c
+++ b/source/pdf/pdf-pattern.c
@@ -16,10 +16,8 @@ static void
pdf_drop_pattern_imp(fz_context *ctx, fz_storable *pat_)
{
pdf_pattern *pat = (pdf_pattern *)pat_;
- if (pat->resources)
- pdf_drop_obj(ctx, pat->resources);
- if (pat->contents)
- pdf_drop_obj(ctx, pat->contents);
+ pdf_drop_obj(ctx, pat->resources);
+ pdf_drop_obj(ctx, pat->contents);
fz_free(ctx, pat);
}
diff --git a/source/pdf/pdf-pkcs7.c b/source/pdf/pdf-pkcs7.c
index 64938fb3..934202e1 100644
--- a/source/pdf/pdf-pkcs7.c
+++ b/source/pdf/pdf-pkcs7.c
@@ -357,8 +357,7 @@ struct pdf_signer_s
void pdf_drop_designated_name(fz_context *ctx, pdf_designated_name *dn)
{
- if (dn)
- fz_free(ctx, dn);
+ fz_free(ctx, dn);
}
static void add_from_bags(X509 **pX509, EVP_PKEY **pPkey, STACK_OF(PKCS12_SAFEBAG) *bags, const char *pw);
diff --git a/source/pdf/pdf-shade.c b/source/pdf/pdf-shade.c
index daa2363a..dd0a9e0a 100644
--- a/source/pdf/pdf-shade.c
+++ b/source/pdf/pdf-shade.c
@@ -416,8 +416,7 @@ pdf_load_shading_dict(fz_context *ctx, pdf_document *doc, pdf_obj *dict, const f
fz_always(ctx)
{
for (i = 0; i < funcs; i++)
- if (func[i])
- fz_drop_function(ctx, func[i]);
+ fz_drop_function(ctx, func[i]);
}
fz_catch(ctx)
{
diff --git a/source/pdf/pdf-type3.c b/source/pdf/pdf-type3.c
index 84912772..3992ebbc 100644
--- a/source/pdf/pdf-type3.c
+++ b/source/pdf/pdf-type3.c
@@ -173,8 +173,7 @@ pdf_load_type3_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *d
}
fz_catch(ctx)
{
- if (fontdesc)
- pdf_drop_font(ctx, fontdesc);
+ pdf_drop_font(ctx, fontdesc);
fz_rethrow(ctx);
}
diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c
index a054a837..814637b9 100644
--- a/source/pdf/pdf-xref.c
+++ b/source/pdf/pdf-xref.c
@@ -1605,26 +1605,21 @@ pdf_drop_document_imp(fz_context *ctx, pdf_document *doc)
* glyph cache at this point. */
fz_purge_glyph_cache(ctx);
- if (doc->js)
- pdf_drop_js(ctx, doc->js);
+ pdf_drop_js(ctx, doc->js);
pdf_drop_xref_sections(ctx, doc);
fz_free(ctx, doc->xref_index);
- if (doc->focus_obj)
- pdf_drop_obj(ctx, doc->focus_obj);
- if (doc->file)
- fz_drop_stream(ctx, doc->file);
- if (doc->crypt)
- pdf_drop_crypt(ctx, doc->crypt);
+ pdf_drop_obj(ctx, doc->focus_obj);
+ fz_drop_stream(ctx, doc->file);
+ pdf_drop_crypt(ctx, doc->crypt);
pdf_drop_obj(ctx, doc->linear_obj);
if (doc->linear_page_refs)
{
for (i=0; i < doc->page_count; i++)
- {
pdf_drop_obj(ctx, doc->linear_page_refs[i]);
- }
+
fz_free(ctx, doc->linear_page_refs);
}
fz_free(ctx, doc->hint_page);
@@ -1648,9 +1643,8 @@ pdf_drop_document_imp(fz_context *ctx, pdf_document *doc)
pdf_drop_resource_tables(ctx, doc);
for (i = 0; i < doc->orphans_count; i++)
- {
pdf_drop_obj(ctx, doc->orphans[i]);
- }
+
fz_free(ctx, doc->orphans);
}
fz_always(ctx)
diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c
index e5d18309..f5d2dc6d 100644
--- a/source/tools/mudraw.c
+++ b/source/tools/mudraw.c
@@ -975,8 +975,7 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in
}
}
- if (list)
- fz_drop_display_list(ctx, list);
+ fz_drop_display_list(ctx, list);
if (!output_append)
file_level_trailers(ctx);
diff --git a/source/xps/xps-resource.c b/source/xps/xps-resource.c
index a625d13b..f12a465d 100644
--- a/source/xps/xps-resource.c
+++ b/source/xps/xps-resource.c
@@ -145,10 +145,8 @@ xps_drop_resource_dictionary(fz_context *ctx, xps_document *doc, xps_resource *d
while (dict)
{
next = dict->next;
- if (dict->base_xml)
- fz_drop_xml(ctx, dict->base_xml);
- if (dict->base_uri)
- fz_free(ctx, dict->base_uri);
+ fz_drop_xml(ctx, dict->base_xml);
+ fz_free(ctx, dict->base_uri);
fz_free(ctx, dict);
dict = next;
}