[cairo-commit] 7 commits - perf/cairo-perf-report.c perf/cairo-perf-trace.c src/cairo-backend-private.h src/cairo-boxes-private.h src/cairo-cff-subset.c src/cairo-default-context-private.h src/cairo-directfb-surface.c src/cairo-error-private.h src/cairo-ft-font.c src/cairo-gl-surface.c src/cairo-gstate.c src/cairoint.h src/cairo-misc.c src/cairo-path.c src/cairo-pattern.c src/cairo-pattern-private.h src/cairo-pdf-shading.c src/cairo-pdf-shading-private.h src/cairo-pdf-surface.c src/cairo-png.c src/cairo-quartz-surface.c src/cairo-scaled-font.c src/cairo-scaled-font-subsets.c src/cairo-script-surface.c src/cairo-stroke-style.c src/cairo-surface.c src/cairo-surface-fallback.c src/cairo-surface-wrapper-private.h src/cairo-toy-font-face.c src/cairo-truetype-subset.c src/cairo-type1-subset.c src/cairo-types-private.h src/cairo-win32-font.c src/cairo-win32-printing-surface.c src/cairo-xcb-connection-core.c src/cairo-xcb-surface-render.c src/cairo-xlib-surface.c test/cairo-test-trace.c ut il/backtrace-symbols.c util/cairo-trace

Andrea Canciani ranma42 at kemper.freedesktop.org
Sun Jul 31 10:22:50 PDT 2011


 perf/cairo-perf-report.c            |    3 --
 perf/cairo-perf-trace.c             |    3 --
 src/cairo-backend-private.h         |    2 -
 src/cairo-boxes-private.h           |    3 ++
 src/cairo-cff-subset.c              |   54 ++++++++++++------------------------
 src/cairo-default-context-private.h |    2 -
 src/cairo-directfb-surface.c        |    6 +---
 src/cairo-error-private.h           |    5 ++-
 src/cairo-ft-font.c                 |    6 +---
 src/cairo-gl-surface.c              |    3 --
 src/cairo-gstate.c                  |    5 +--
 src/cairo-misc.c                    |    6 +---
 src/cairo-path.c                    |    3 --
 src/cairo-pattern-private.h         |    3 --
 src/cairo-pattern.c                 |    2 -
 src/cairo-pdf-shading-private.h     |    2 -
 src/cairo-pdf-shading.c             |    2 -
 src/cairo-pdf-surface.c             |   15 +++-------
 src/cairo-png.c                     |    6 +---
 src/cairo-quartz-surface.c          |    6 +---
 src/cairo-scaled-font-subsets.c     |   21 ++++----------
 src/cairo-scaled-font.c             |    6 +---
 src/cairo-script-surface.c          |   20 +++++--------
 src/cairo-stroke-style.c            |    7 ++--
 src/cairo-surface-fallback.c        |    3 --
 src/cairo-surface-wrapper-private.h |    1 
 src/cairo-surface.c                 |    5 +--
 src/cairo-toy-font-face.c           |    4 --
 src/cairo-truetype-subset.c         |   18 ++++--------
 src/cairo-type1-subset.c            |    9 ++----
 src/cairo-types-private.h           |    1 
 src/cairo-win32-font.c              |   29 ++++++-------------
 src/cairo-win32-printing-surface.c  |    3 --
 src/cairo-xcb-connection-core.c     |    3 --
 src/cairo-xcb-surface-render.c      |    3 --
 src/cairo-xlib-surface.c            |    6 +---
 src/cairoint.h                      |    4 +-
 test/cairo-test-trace.c             |    6 +---
 util/backtrace-symbols.c            |    6 +---
 util/cairo-trace/lookup-symbol.c    |    3 --
 40 files changed, 106 insertions(+), 189 deletions(-)

New commits:
commit e04e3687485a1988fd4084cca07ca4db4e2e7b96
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Sat Jul 30 11:04:16 2011 +0200

    Remove useless checks for NULL before freeing
    
    This patch has been generated by the following Coccinelle semantic patch:
    // Remove useless checks for NULL before freeing
    //
    // free (NULL) is a no-op, so there is no need to avoid it
    
    @@
    expression E;
    @@
    + free (E);
    + E = NULL;
    - if (unlikely (E != NULL)) {
    -   free(E);
    (
    -   E = NULL;
    |
    -   E = 0;
    )
       ...
    - }
    
    @@
    expression E;
    @@
    + free (E);
    - if (unlikely (E != NULL)) {
    -   free (E);
    - }

diff --git a/perf/cairo-perf-report.c b/perf/cairo-perf-report.c
index 8ab8090..a04db6b 100644
--- a/perf/cairo-perf-report.c
+++ b/perf/cairo-perf-report.c
@@ -505,8 +505,7 @@ cairo_perf_report_load (cairo_perf_report_t *report,
 	/* Do nothing on TEST_REPORT_STATUS_COMMENT */
     }
 
-    if (line)
-	free (line);
+    free (line);
 
     if (filename != NULL)
 	fclose (file);
diff --git a/perf/cairo-perf-trace.c b/perf/cairo-perf-trace.c
index ff22882..587e628 100644
--- a/perf/cairo-perf-trace.c
+++ b/perf/cairo-perf-trace.c
@@ -614,8 +614,7 @@ read_excludes (cairo_perf_t *perf,
 	    perf->num_exclude_names++;
 	}
     }
-    if (line != NULL)
-	free (line);
+    free (line);
 
     fclose (file);
 
diff --git a/src/cairo-cff-subset.c b/src/cairo-cff-subset.c
index 3dabc92..d311514 100644
--- a/src/cairo-cff-subset.c
+++ b/src/cairo-cff-subset.c
@@ -2702,10 +2702,8 @@ fail3:
     free (font->subset_font_name);
 fail2:
     free (font->data);
-    if (font->font_name)
-	free (font->font_name);
-    if (font->ps_name)
-	free (font->ps_name);
+    free (font->font_name);
+    free (font->ps_name);
     _cairo_array_fini (&font->output);
 fail1:
     free (font);
@@ -2719,8 +2717,7 @@ cairo_cff_font_destroy (cairo_cff_font_t *font)
     unsigned int i;
 
     free (font->widths);
-    if (font->font_name)
-	free (font->font_name);
+    free (font->font_name);
     free (font->ps_name);
     free (font->subset_font_name);
     _cairo_array_fini (&font->output);
@@ -2742,20 +2739,14 @@ cairo_cff_font_destroy (cairo_cff_font_t *font)
         }
         free (font->fd_dict);
     }
-    if (font->global_subs_used)
-	free (font->global_subs_used);
-    if (font->local_subs_used)
-	free (font->local_subs_used);
-    if (font->fd_subset_map)
-        free (font->fd_subset_map);
-    if (font->private_dict_offset)
-        free (font->private_dict_offset);
+    free (font->global_subs_used);
+    free (font->local_subs_used);
+    free (font->fd_subset_map);
+    free (font->private_dict_offset);
 
     if (font->is_cid) {
-        if (font->fdselect)
-            free (font->fdselect);
-        if (font->fdselect_subset)
-            free (font->fdselect_subset);
+	free (font->fdselect);
+	free (font->fdselect_subset);
         if (font->fd_private_dict) {
             for (i = 0; i < font->num_fontdicts; i++) {
                 if (font->fd_private_dict[i])
@@ -2768,23 +2759,18 @@ cairo_cff_font_destroy (cairo_cff_font_t *font)
                 cff_index_fini (&font->fd_local_sub_index[i]);
             free (font->fd_local_sub_index);
         }
-        if (font->fd_local_sub_bias)
-            free (font->fd_local_sub_bias);
+	free (font->fd_local_sub_bias);
         if (font->fd_local_subs_used) {
             for (i = 0; i < font->num_fontdicts; i++) {
-                if (font->fd_local_subs_used[i])
-                    free (font->fd_local_subs_used[i]);
+		free (font->fd_local_subs_used[i]);
             }
             free (font->fd_local_subs_used);
         }
-        if (font->fd_default_width)
-            free (font->fd_default_width);
-        if (font->fd_nominal_width)
-            free (font->fd_nominal_width);
+	free (font->fd_default_width);
+	free (font->fd_nominal_width);
     }
 
-    if (font->data)
-        free (font->data);
+    free (font->data);
 
     free (font);
 }
@@ -2855,8 +2841,7 @@ _cairo_cff_subset_init (cairo_cff_subset_t          *cff_subset,
  fail4:
     free (cff_subset->widths);
  fail3:
-    if (cff_subset->font_name)
-	free (cff_subset->font_name);
+    free (cff_subset->font_name);
  fail2:
     free (cff_subset->ps_name);
  fail1:
@@ -2869,8 +2854,7 @@ void
 _cairo_cff_subset_fini (cairo_cff_subset_t *subset)
 {
     free (subset->ps_name);
-    if (subset->font_name)
-	free (subset->font_name);
+    free (subset->font_name);
     free (subset->widths);
     free (subset->data);
 }
@@ -2977,8 +2961,7 @@ fail2:
     cff_index_fini (&index);
 
 fail1:
-    if (data)
-	free (data);
+    free (data);
 
     return is_cid;
 }
@@ -3066,8 +3049,7 @@ fail5:
 fail4:
     free (font->widths);
 fail3:
-    if (font->font_name)
-	free (font->font_name);
+    free (font->font_name);
     free (font->ps_name);
 fail2:
     free (font->subset_font_name);
diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index c46f587..46c0960 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -1711,10 +1711,8 @@ _cairo_directfb_surface_scaled_glyph_fini (cairo_scaled_glyph_t *scaled_glyph,
                  "%s( scaled_glyph=%p, scaled_font=%p ).\n",
                  __FUNCTION__, scaled_glyph, scaled_font);
 
-     if (scaled_glyph->surface_private != NULL) {
-          free (scaled_glyph->surface_private);
-          scaled_glyph->surface_private = NULL;
-     }
+     free (scaled_glyph->surface_private);
+     scaled_glyph->surface_private = NULL;
 }
 
 static cairo_int_status_t
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index a603ada..c490d69 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -431,10 +431,8 @@ _cairo_ft_unscaled_font_fini (cairo_ft_unscaled_font_t *unscaled)
 {
     assert (unscaled->face == NULL);
 
-    if (unscaled->filename) {
-	free (unscaled->filename);
-	unscaled->filename = NULL;
-    }
+    free (unscaled->filename);
+    unscaled->filename = NULL;
 
     CAIRO_MUTEX_FINI (unscaled->mutex);
 }
diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index 09a1589..f6c96ae 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -825,8 +825,7 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
 						    data_start);
 
 
-	if (data_start_gles2)
-	    free (data_start_gles2);
+	free (data_start_gles2);
 
 	/* If we just treated some rgb-only data as rgba, then we have to
 	 * go back and fix up the alpha channel where we filled in this
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 11a7b51..1d59fc5 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -517,8 +517,7 @@ _cairo_gstate_set_dash (cairo_gstate_t *gstate, const double *dash, int num_dash
     unsigned int i;
     double dash_total;
 
-    if (gstate->stroke_style.dash)
-	free (gstate->stroke_style.dash);
+    free (gstate->stroke_style.dash);
 
     gstate->stroke_style.num_dashes = num_dashes;
 
diff --git a/src/cairo-misc.c b/src/cairo-misc.c
index c04fe11..27c264b 100644
--- a/src/cairo-misc.c
+++ b/src/cairo-misc.c
@@ -207,8 +207,7 @@ slim_hidden_def (cairo_glyph_allocate);
 void
 cairo_glyph_free (cairo_glyph_t *glyphs)
 {
-    if (glyphs)
-	free (glyphs);
+    free (glyphs);
 }
 slim_hidden_def (cairo_glyph_free);
 
@@ -258,8 +257,7 @@ slim_hidden_def (cairo_text_cluster_allocate);
 void
 cairo_text_cluster_free (cairo_text_cluster_t *clusters)
 {
-    if (clusters)
-	free (clusters);
+    free (clusters);
 }
 slim_hidden_def (cairo_text_cluster_free);
 
diff --git a/src/cairo-path.c b/src/cairo-path.c
index 16447a4..d3d9131 100644
--- a/src/cairo-path.c
+++ b/src/cairo-path.c
@@ -365,8 +365,7 @@ cairo_path_destroy (cairo_path_t *path)
     if (path == NULL || path == &_cairo_path_nil)
 	return;
 
-    if (path->data)
-	free (path->data);
+    free (path->data);
 
     free (path);
 }
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index d6f382b..9b5bed2 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -1021,12 +1021,9 @@ _cairo_pdf_smask_group_destroy (cairo_pdf_smask_group_t *group)
 	cairo_pattern_destroy (group->source);
     if (group->mask)
 	cairo_pattern_destroy (group->mask);
-    if (group->utf8)
-	free (group->utf8);
-    if (group->glyphs)
-	free (group->glyphs);
-    if (group->clusters)
-	free (group->clusters);
+    free (group->utf8);
+    free (group->glyphs);
+    free (group->clusters);
     if (group->scaled_font)
 	cairo_scaled_font_destroy (group->scaled_font);
     free (group);
@@ -1662,8 +1659,7 @@ _cairo_pdf_source_surface_entry_pluck (void *entry, void *closure)
     cairo_hash_table_t *patterns = closure;
 
     _cairo_hash_table_remove (patterns, &surface_entry->base);
-    if (surface_entry->unique_id)
-	free (surface_entry->unique_id);
+    free (surface_entry->unique_id);
 
     free (surface_entry);
 }
@@ -3877,8 +3873,7 @@ _cairo_pdf_surface_emit_unicode_for_glyph (cairo_pdf_surface_t	*surface,
     }
     _cairo_output_stream_printf (surface->output, ">");
 
-    if (utf16)
-	free (utf16);
+    free (utf16);
 
     return CAIRO_STATUS_SUCCESS;
 }
diff --git a/src/cairo-png.c b/src/cairo-png.c
index 5468096..818b7b0 100644
--- a/src/cairo-png.c
+++ b/src/cairo-png.c
@@ -709,10 +709,8 @@ read_png (struct png_read_closure_t *png_closure)
     }
 
  BAIL:
-    if (row_pointers != NULL)
-	free (row_pointers);
-    if (data != NULL)
-	free (data);
+    free (row_pointers);
+    free (data);
     if (png != NULL)
 	png_destroy_read_struct (&png, &info, NULL);
     if (png_closure->png_data != NULL) {
diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index 0f481a0..23b2b33 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -1500,10 +1500,8 @@ _cairo_quartz_surface_finish (void *abstract_surface)
 	surface->imageSurfaceEquiv = NULL;
     }
 
-    if (surface->imageData) {
-	free (surface->imageData);
-	surface->imageData = NULL;
-    }
+    free (surface->imageData);
+    surface->imageData = NULL;
 
     return CAIRO_STATUS_SUCCESS;
 }
diff --git a/src/cairo-scaled-font-subsets.c b/src/cairo-scaled-font-subsets.c
index dd6b824..d3d9d65 100644
--- a/src/cairo-scaled-font-subsets.c
+++ b/src/cairo-scaled-font-subsets.c
@@ -198,8 +198,7 @@ _cairo_sub_font_glyph_create (unsigned long	scaled_font_glyph_index,
 static void
 _cairo_sub_font_glyph_destroy (cairo_sub_font_glyph_t *sub_font_glyph)
 {
-    if (sub_font_glyph->utf8 != NULL)
-	free (sub_font_glyph->utf8);
+    free (sub_font_glyph->utf8);
 
     free (sub_font_glyph);
 }
@@ -1028,14 +1027,10 @@ _cairo_scaled_font_subsets_foreach_internal (cairo_scaled_font_subsets_t
 		  collection.utf8 == NULL ||
 		  collection.to_latin_char == NULL ||
 		  collection.latin_to_subset_glyph_index == NULL)) {
-	if (collection.glyphs != NULL)
-	    free (collection.glyphs);
-	if (collection.utf8 != NULL)
-	    free (collection.utf8);
-	if (collection.to_latin_char != NULL)
-	    free (collection.to_latin_char);
-	if (collection.latin_to_subset_glyph_index != NULL)
-	    free (collection.latin_to_subset_glyph_index);
+	free (collection.glyphs);
+	free (collection.utf8);
+	free (collection.to_latin_char);
+	free (collection.latin_to_subset_glyph_index);
 
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
@@ -1205,8 +1200,7 @@ _cairo_scaled_font_subset_create_glyph_names (cairo_scaled_font_subset_t *subset
 	} else {
 	    snprintf (buf, sizeof (buf), "g%d", i);
 	}
-	if (utf16)
-	    free (utf16);
+	free (utf16);
 
 	subset->glyph_names[i] = strdup (buf);
 	if (unlikely (subset->glyph_names[i] == NULL)) {
@@ -1234,8 +1228,7 @@ CLEANUP_HASH:
 
     if (subset->glyph_names != NULL) {
 	for (i = 0; i < subset->num_glyphs; i++) {
-	    if (subset->glyph_names[i] != NULL)
-		free (subset->glyph_names[i]);
+	    free (subset->glyph_names[i]);
 	}
 
 	free (subset->glyph_names);
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index efab44f..6dc8ed3 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -1159,10 +1159,8 @@ _cairo_scaled_font_reset_static_data (void)
 	 status <= CAIRO_STATUS_LAST_STATUS;
 	 status++)
     {
-	if (_cairo_scaled_font_nil_objects[status] != NULL) {
-	    free (_cairo_scaled_font_nil_objects[status]);
-	    _cairo_scaled_font_nil_objects[status] = NULL;
-	}
+	free (_cairo_scaled_font_nil_objects[status]);
+	_cairo_scaled_font_nil_objects[status] = NULL;
     }
     CAIRO_MUTEX_UNLOCK (_cairo_scaled_font_error_mutex);
 
diff --git a/src/cairo-script-surface.c b/src/cairo-script-surface.c
index 699b6c3..e61b8a4 100644
--- a/src/cairo-script-surface.c
+++ b/src/cairo-script-surface.c
@@ -778,10 +778,8 @@ _emit_dash (cairo_script_surface_t *surface,
 	memcpy (surface->cr.current_style.dash, dash,
 		sizeof (double) * num_dashes);
     } else {
-	if (surface->cr.current_style.dash != NULL) {
-	    free (surface->cr.current_style.dash);
-	    surface->cr.current_style.dash = NULL;
-	}
+	free (surface->cr.current_style.dash);
+	surface->cr.current_style.dash = NULL;
     }
 
     surface->cr.current_style.num_dashes = num_dashes;
@@ -1989,10 +1987,9 @@ _cairo_script_surface_finish (void *abstract_surface)
 
     _cairo_surface_wrapper_fini (&surface->wrapper);
 
-    if (surface->cr.current_style.dash != NULL) {
-	free (surface->cr.current_style.dash);
-	surface->cr.current_style.dash = NULL;
-    }
+    free (surface->cr.current_style.dash);
+    surface->cr.current_style.dash = NULL;
+
     _cairo_pattern_fini (&surface->cr.current_source.base);
     _cairo_path_fixed_fini (&surface->cr.current_path);
     _cairo_surface_clipper_reset (&surface->clipper);
@@ -3482,10 +3479,9 @@ _cairo_script_implicit_context_init (cairo_script_implicit_context_t *cr)
 static void
 _cairo_script_implicit_context_reset (cairo_script_implicit_context_t *cr)
 {
-    if (cr->current_style.dash != NULL) {
-	free (cr->current_style.dash);
-	cr->current_style.dash = NULL;
-    }
+    free (cr->current_style.dash);
+    cr->current_style.dash = NULL;
+
     _cairo_pattern_fini (&cr->current_source.base);
     _cairo_path_fixed_fini (&cr->current_path);
 
diff --git a/src/cairo-stroke-style.c b/src/cairo-stroke-style.c
index 1513d1f..b9c3a0d 100644
--- a/src/cairo-stroke-style.c
+++ b/src/cairo-stroke-style.c
@@ -86,10 +86,9 @@ _cairo_stroke_style_init_copy (cairo_stroke_style_t *style,
 void
 _cairo_stroke_style_fini (cairo_stroke_style_t *style)
 {
-    if (style->dash) {
-	free (style->dash);
-	style->dash = NULL;
-    }
+    free (style->dash);
+    style->dash = NULL;
+
     style->num_dashes = 0;
 
     VG (VALGRIND_MAKE_MEM_NOACCESS (style, sizeof (cairo_stroke_style_t)));
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index 95d3c17..acbf799 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -1528,8 +1528,7 @@ _cairo_surface_fallback_composite_trapezoids (cairo_operator_t		op,
 						  traps, num_traps,
 						  clip_region);
  FAIL:
-    if (offset_traps != NULL)
-	free (offset_traps);
+    free (offset_traps);
 
     if (fallback_region != NULL)
 	cairo_region_destroy (fallback_region);
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 7c6d2e6..592eeef 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -1170,8 +1170,7 @@ cairo_surface_set_mime_data (cairo_surface_t		*surface,
 					      mime_data,
 					      _cairo_mime_data_destroy);
     if (unlikely (status)) {
-	if (mime_data != NULL)
-	    free (mime_data);
+	free (mime_data);
 
 	return _cairo_surface_set_error (surface, status);
     }
diff --git a/src/cairo-truetype-subset.c b/src/cairo-truetype-subset.c
index 844e521..88c4ee3 100644
--- a/src/cairo-truetype-subset.c
+++ b/src/cairo-truetype-subset.c
@@ -269,8 +269,7 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t  *scaled_font_subset,
     free (font->base.ps_name);
  fail3:
     free (font->parent_to_subset);
-    if (font->base.font_name)
-	free (font->base.font_name);
+    free (font->base.font_name);
  fail2:
     free (font->glyphs);
  fail1:
@@ -286,8 +285,7 @@ cairo_truetype_font_destroy (cairo_truetype_font_t *font)
     _cairo_array_fini (&font->string_offsets);
     free (font->base.widths);
     free (font->base.ps_name);
-    if (font->base.font_name)
-	free (font->base.font_name);
+    free (font->base.font_name);
     free (font->parent_to_subset);
     free (font->glyphs);
     _cairo_array_fini (&font->output);
@@ -1201,8 +1199,7 @@ cairo_truetype_subset_init_internal (cairo_truetype_subset_t     *truetype_subse
  fail4:
     free (truetype_subset->widths);
  fail3:
-    if (truetype_subset->font_name)
-	free (truetype_subset->font_name);
+    free (truetype_subset->font_name);
  fail2:
     free (truetype_subset->ps_name);
  fail1:
@@ -1229,8 +1226,7 @@ void
 _cairo_truetype_subset_fini (cairo_truetype_subset_t *subset)
 {
     free (subset->ps_name);
-    if (subset->font_name)
-	free (subset->font_name);
+    free (subset->font_name);
     free (subset->widths);
     free (subset->data);
     free (subset->string_offsets);
@@ -1493,11 +1489,9 @@ _cairo_truetype_read_font_name (cairo_scaled_font_t  	 *scaled_font,
 fail:
     free (name);
 
-    if (ps_name != NULL)
-	free (ps_name);
+    free (ps_name);
 
-    if (font_name != NULL)
-	free (font_name);
+    free (font_name);
 
     *ps_name_out = NULL;
     *font_name_out = NULL;
diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c
index 6c94a83..a637e24 100644
--- a/src/cairo-type1-subset.c
+++ b/src/cairo-type1-subset.c
@@ -1492,17 +1492,14 @@ _cairo_type1_font_subset_fini (cairo_type1_font_subset_t *font)
     _cairo_array_fini (&font->glyph_names_array);
     _cairo_array_fini (&font->glyphs_array);
 
-    if (font->subrs)
-	free (font->subrs);
+    free (font->subrs);
 
     if (font->output != NULL)
 	status = _cairo_output_stream_destroy (font->output);
 
-    if (font->base.base_font)
-	free (font->base.base_font);
+    free (font->base.base_font);
 
-    if (font->subset_index_to_glyphs)
-	free (font->subset_index_to_glyphs);
+    free (font->subset_index_to_glyphs);
 
     return status;
 }
diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c
index e07a515..1bd1104 100644
--- a/src/cairo-win32-font.c
+++ b/src/cairo-win32-font.c
@@ -780,14 +780,11 @@ _cairo_win32_scaled_font_text_to_glyphs (void		*abstract_font,
 	goto FAIL1;
 
     while (TRUE) {
-	if (glyph_indices) {
-	    free (glyph_indices);
-	    glyph_indices = NULL;
-	}
-	if (dx) {
-	    free (dx);
-	    dx = NULL;
-	}
+	free (glyph_indices);
+	glyph_indices = NULL;
+
+	free (dx);
+	dx = NULL;
 
 	glyph_indices = _cairo_malloc_ab (buffer_size, sizeof (WCHAR));
 	dx = _cairo_malloc_ab (buffer_size, sizeof (int));
@@ -840,10 +837,8 @@ _cairo_win32_scaled_font_text_to_glyphs (void		*abstract_font,
     }
 
  FAIL2:
-    if (glyph_indices)
-	free (glyph_indices);
-    if (dx)
-	free (dx);
+    free (glyph_indices);
+    free (dx);
 
     cairo_win32_scaled_font_done_font (&scaled_font->base);
 
@@ -1624,10 +1619,8 @@ _cairo_win32_scaled_font_index_to_ucs4 (void		*abstract_font,
     }
 
 exit2:
-    if (glyph_indices)
-	free (glyph_indices);
-    if (utf16)
-	free (utf16);
+    free (glyph_indices);
+    free (utf16);
     free (glyph_set);
 exit1:
     cairo_win32_scaled_font_done_font (&scaled_font->base);
diff --git a/src/cairo-win32-printing-surface.c b/src/cairo-win32-printing-surface.c
index 5cd3cee..a91805e 100644
--- a/src/cairo-win32-printing-surface.c
+++ b/src/cairo-win32-printing-surface.c
@@ -1363,8 +1363,7 @@ _cairo_win32_printing_surface_stroke (void			*abstract_surface,
     }
     RestoreDC (surface->dc, -1);
     DeleteObject (pen);
-    if (dash_array)
-	free (dash_array);
+    free (dash_array);
 
     return status;
 }
diff --git a/src/cairo-xcb-connection-core.c b/src/cairo-xcb-connection-core.c
index 5a20004..fe86876 100644
--- a/src/cairo-xcb-connection-core.c
+++ b/src/cairo-xcb-connection-core.c
@@ -262,8 +262,7 @@ _cairo_xcb_connection_get_image (cairo_xcb_connection_t *connection,
     if (error) {
 	free (error);
 
-	if (*reply)
-	    free (*reply);
+	free (*reply);
 	*reply = NULL;
     }
 
diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c
index 1d514fc..364e5c0 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -4056,8 +4056,7 @@ _cairo_xcb_font_destroy (cairo_xcb_font_t *font)
 
 	glyphset_info = &font->glyphset_info[i];
 
-	if (glyphset_info->pending_free_glyphs != NULL)
-	    free (glyphset_info->pending_free_glyphs);
+	free (glyphset_info->pending_free_glyphs);
     }
 
     cairo_list_del (&font->link);
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index b4a084a..57b2604 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -3941,8 +3941,7 @@ _cairo_xlib_surface_remove_scaled_font (cairo_xlib_display_t	*display,
 	    if (glyphset_info->glyphset)
 		XRenderFreeGlyphSet (display->display, glyphset_info->glyphset);
 
-	    if (glyphset_info->pending_free_glyphs != NULL)
-		free (glyphset_info->pending_free_glyphs);
+	    free (glyphset_info->pending_free_glyphs);
 	}
 
 	cairo_device_destroy (font_private->device);
@@ -4013,8 +4012,7 @@ _cairo_xlib_surface_scaled_font_fini (cairo_scaled_font_t *scaled_font)
 
 	    glyphset_info = &font_private->glyphset_info[i];
 
-	    if (glyphset_info->pending_free_glyphs != NULL)
-		free (glyphset_info->pending_free_glyphs);
+	    free (glyphset_info->pending_free_glyphs);
 
 	    if (glyphset_info->glyphset) {
 		status = _cairo_xlib_display_queue_resource (display,
diff --git a/test/cairo-test-trace.c b/test/cairo-test-trace.c
index 1564319..96039ab 100644
--- a/test/cairo-test-trace.c
+++ b/test/cairo-test-trace.c
@@ -1496,8 +1496,7 @@ read_excludes (test_trace_t *test, const char *filename)
 	    test->num_exclude_names++;
 	}
     }
-    if (line != NULL)
-	free (line);
+    free (line);
 
     fclose (file);
 
@@ -1583,8 +1582,7 @@ test_fini (test_trace_t *test)
     test_reset (test);
 
     cairo_boilerplate_free_targets (test->targets);
-    if (test->exclude_names)
-	free (test->exclude_names);
+    free (test->exclude_names);
 }
 
 static cairo_bool_t
diff --git a/util/backtrace-symbols.c b/util/backtrace-symbols.c
index 83f2425..045ad78 100644
--- a/util/backtrace-symbols.c
+++ b/util/backtrace-symbols.c
@@ -273,10 +273,8 @@ static char **process_file(const char *file_name, bfd_vma *addr, int naddr)
 
 	ret_buf = translate_addresses_buf(abfd, addr, naddr);
 
-	if (syms != NULL) {
-		free(syms);
-		syms = NULL;
-	}
+	free (syms);
+	syms = NULL;
 
 	bfd_close(abfd);
 	return ret_buf;
diff --git a/util/cairo-trace/lookup-symbol.c b/util/cairo-trace/lookup-symbol.c
index eb1a656..f9665b3 100644
--- a/util/cairo-trace/lookup-symbol.c
+++ b/util/cairo-trace/lookup-symbol.c
@@ -85,8 +85,7 @@ struct symbol {
 static void
 _symtab_fini (struct symtab *symtab)
 {
-    if (symtab->syms != NULL)
-	free (symtab->syms);
+    free (symtab->syms);
     if (symtab->bfd != NULL)
 	bfd_close (symtab->bfd);
 }
commit 8f8da19fd47a51724e035a076628d38fde48863c
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Sat Jul 30 18:29:29 2011 +0200

    font-face: Cleanup backend-specific destruction code
    
    The check for NULL and nil font faces is performed in the shared
    code. There is no need to duplicate it (in fact, quartz-font and
    ft-font don't do it).

diff --git a/src/cairo-toy-font-face.c b/src/cairo-toy-font-face.c
index e82d535..363b9a2 100644
--- a/src/cairo-toy-font-face.c
+++ b/src/cairo-toy-font-face.c
@@ -348,10 +348,6 @@ _cairo_toy_font_face_destroy (void *abstract_face)
     cairo_toy_font_face_t *font_face = abstract_face;
     cairo_hash_table_t *hash_table;
 
-    if (font_face == NULL ||
-	    CAIRO_REFERENCE_COUNT_IS_INVALID (&font_face->base.ref_count))
-	return;
-
     hash_table = _cairo_toy_font_face_hash_table_lock ();
     /* All created objects must have been mapped in the hash table. */
     assert (hash_table != NULL);
diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c
index 34b7179..e07a515 100644
--- a/src/cairo-win32-font.c
+++ b/src/cairo-win32-font.c
@@ -2098,10 +2098,6 @@ _cairo_win32_font_face_destroy (void *abstract_face)
     cairo_win32_font_face_t *font_face = abstract_face;
     cairo_hash_table_t *hash_table;
 
-    if (font_face == NULL ||
-	    CAIRO_REFERENCE_COUNT_IS_INVALID (&font_face->base.ref_count))
-	return;
-
     hash_table = _cairo_win32_font_face_hash_table_lock ();
     /* All created objects must have been mapped in the hash table. */
     assert (hash_table != NULL);
commit 1f2dc2e06a2c2daabeefbea4c32cdf55bdf6b338
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Mon Jul 18 11:19:35 2011 +0200

    pattern: Do not provide type field in cairo_pattern_union_t
    
    The type field is accessible through the base.type field. This makes
    it possible to change the layout of cairo_pattern_t and move the type
    field without breaking cairo_pattern_union_t.

diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index fd5c7b3..11a7b51 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -1062,7 +1062,7 @@ _cairo_gstate_mask (cairo_gstate_t  *gstate,
     _cairo_gstate_copy_transformed_mask (gstate, &mask_pattern.base, mask);
 
     if (source->type == CAIRO_PATTERN_TYPE_SOLID &&
-	mask_pattern.type == CAIRO_PATTERN_TYPE_SOLID &&
+	mask_pattern.base.type == CAIRO_PATTERN_TYPE_SOLID &&
 	_cairo_operator_bounded_by_source (op))
     {
 	const cairo_solid_pattern_t *solid = (cairo_solid_pattern_t *) source;
diff --git a/src/cairo-pattern-private.h b/src/cairo-pattern-private.h
index fc6f8eb..647eb0b 100644
--- a/src/cairo-pattern-private.h
+++ b/src/cairo-pattern-private.h
@@ -165,7 +165,6 @@ typedef struct _cairo_mesh_pattern {
 } cairo_mesh_pattern_t;
 
 typedef union {
-    cairo_pattern_type_t	    type;
     cairo_pattern_t		    base;
 
     cairo_solid_pattern_t	    solid;
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 13aad6f..cb6bba8 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -3674,7 +3674,7 @@ _cairo_pattern_is_clear (const cairo_pattern_t *abstract_pattern)
 	return FALSE;
 
     pattern = (cairo_pattern_union_t *) abstract_pattern;
-    switch (pattern->type) {
+    switch (abstract_pattern->type) {
     case CAIRO_PATTERN_TYPE_SOLID:
 	return CAIRO_COLOR_IS_CLEAR (&pattern->solid.color);
     case CAIRO_PATTERN_TYPE_SURFACE:
commit b39d3d4b53951f951a3af188dd55acf2e0fa8eda
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Sat Jul 30 15:35:24 2011 +0200

    surface: Set errors through _cairo_surface_set_status()
    
    The status should never be set directly. Instead, it should be set by
    _cairo_surface_set_status().

diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index cb05ff6..7c6d2e6 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -702,7 +702,7 @@ error:
     cairo_surface_finish (image);
     cairo_surface_destroy (image);
     if (status)
-	_cairo_status_set_error (&surface->status, status);
+	_cairo_surface_set_error (surface, status);
 }
 
 cairo_surface_t *
commit ed928c51fb33d36619d74367b1ebd06300f80417
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Sat Jul 30 11:44:12 2011 +0200

    Tighten error validation
    
    CAIRO_STATUS_LAST_STATUS is not an error, it is just the number of
    possible status values.

diff --git a/src/cairo-error-private.h b/src/cairo-error-private.h
index c1180e1..1c82ae6 100644
--- a/src/cairo-error-private.h
+++ b/src/cairo-error-private.h
@@ -98,10 +98,10 @@ enum _cairo_int_status {
 };
 
 #define _cairo_status_is_error(status) \
-    (status != CAIRO_STATUS_SUCCESS && status <= CAIRO_STATUS_LAST_STATUS)
+    (status != CAIRO_STATUS_SUCCESS && status < CAIRO_STATUS_LAST_STATUS)
 
 #define _cairo_int_status_is_error(status) \
-    (status != CAIRO_INT_STATUS_SUCCESS && status <= CAIRO_INT_STATUS_LAST_STATUS)
+    (status != CAIRO_INT_STATUS_SUCCESS && status < CAIRO_INT_STATUS_LAST_STATUS)
 
 static inline cairo_status_t
 _cairo_public_status (cairo_int_status_t status)
commit 90216cfde01900839a722424ae0047f1fbd0c01f
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Sat Jul 30 15:37:45 2011 +0200

    Update FSF address
    
    I updated the Free Software Foundation address using the following script.
    
    for i in $(git grep Temple | cut -d: -f1 )
    do
      sed -e 's/59 Temple Place[, -]* Suite 330, Boston, MA *02111-1307[, ]* USA/51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA/' -i "$i"
    done

diff --git a/src/cairo-backend-private.h b/src/cairo-backend-private.h
index 720b28c..e09b436 100644
--- a/src/cairo-backend-private.h
+++ b/src/cairo-backend-private.h
@@ -12,7 +12,7 @@
  *
  * You should have received a copy of the LGPL along with this library
  * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
  * You should have received a copy of the MPL along with this library
  * in the file COPYING-MPL-1.1
  *
diff --git a/src/cairo-default-context-private.h b/src/cairo-default-context-private.h
index e2d780d..32fd12d 100644
--- a/src/cairo-default-context-private.h
+++ b/src/cairo-default-context-private.h
@@ -12,7 +12,7 @@
  *
  * You should have received a copy of the LGPL along with this library
  * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
  * You should have received a copy of the MPL along with this library
  * in the file COPYING-MPL-1.1
  *
diff --git a/src/cairo-pattern-private.h b/src/cairo-pattern-private.h
index af9cb43..fc6f8eb 100644
--- a/src/cairo-pattern-private.h
+++ b/src/cairo-pattern-private.h
@@ -12,7 +12,7 @@
  *
  * You should have received a copy of the LGPL along with this library
  * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
  * You should have received a copy of the MPL along with this library
  * in the file COPYING-MPL-1.1
  *
diff --git a/src/cairo-pdf-shading-private.h b/src/cairo-pdf-shading-private.h
index f059d7f..0ca8cb7 100644
--- a/src/cairo-pdf-shading-private.h
+++ b/src/cairo-pdf-shading-private.h
@@ -13,7 +13,7 @@
  *
  * You should have received a copy of the LGPL along with this library
  * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
  * You should have received a copy of the MPL along with this library
  * in the file COPYING-MPL-1.1
  *
diff --git a/src/cairo-pdf-shading.c b/src/cairo-pdf-shading.c
index 8a277ac..6b7bcea 100644
--- a/src/cairo-pdf-shading.c
+++ b/src/cairo-pdf-shading.c
@@ -13,7 +13,7 @@
  *
  * You should have received a copy of the LGPL along with this library
  * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
  * You should have received a copy of the MPL along with this library
  * in the file COPYING-MPL-1.1
  *
commit f6b30686ca637b504d6caabb40773f1aadcee3fe
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Sat Jul 30 18:14:51 2011 +0200

    Fix make check
    
    This fixes multiple failures when checking if headers can be used
    standalone.

diff --git a/src/cairo-boxes-private.h b/src/cairo-boxes-private.h
index 619545f..890d1b2 100644
--- a/src/cairo-boxes-private.h
+++ b/src/cairo-boxes-private.h
@@ -37,6 +37,9 @@
 #include "cairo-types-private.h"
 #include "cairo-compiler-private.h"
 
+#include <stdio.h>
+#include <stdlib.h>
+
 struct _cairo_boxes_t {
     cairo_status_t status;
     cairo_box_t limit;
diff --git a/src/cairo-error-private.h b/src/cairo-error-private.h
index 5f517d4..c1180e1 100644
--- a/src/cairo-error-private.h
+++ b/src/cairo-error-private.h
@@ -40,6 +40,7 @@
 
 #include "cairo.h"
 #include "cairo-compiler-private.h"
+#include "cairo-types-private.h"
 
 #include <assert.h>
 
diff --git a/src/cairo-surface-wrapper-private.h b/src/cairo-surface-wrapper-private.h
index cce08e1..fbe5d80 100644
--- a/src/cairo-surface-wrapper-private.h
+++ b/src/cairo-surface-wrapper-private.h
@@ -39,6 +39,7 @@
 #ifndef CAIRO_SURFACE_WRAPPER_PRIVATE_H
 #define CAIRO_SURFACE_WRAPPER_PRIVATE_H
 
+#include "cairoint.h"
 #include "cairo-types-private.h"
 
 CAIRO_BEGIN_DECLS
diff --git a/src/cairo-types-private.h b/src/cairo-types-private.h
index bed6412..c797c1a 100644
--- a/src/cairo-types-private.h
+++ b/src/cairo-types-private.h
@@ -78,6 +78,7 @@ typedef struct _cairo_rectangle_int16 cairo_glyph_size_t;
 typedef struct _cairo_scaled_font_backend   cairo_scaled_font_backend_t;
 typedef struct _cairo_scaled_font_subsets cairo_scaled_font_subsets_t;
 typedef struct _cairo_solid_pattern cairo_solid_pattern_t;
+typedef struct _cairo_surface_attributes cairo_surface_attributes_t;
 typedef struct _cairo_surface_backend cairo_surface_backend_t;
 typedef struct _cairo_surface_snapshot cairo_surface_snapshot_t;
 typedef struct _cairo_surface_subsurface cairo_surface_subsurface_t;
diff --git a/src/cairoint.h b/src/cairoint.h
index bbe26a8..33c9a49 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -976,7 +976,7 @@ extern const cairo_private cairo_solid_pattern_t _cairo_pattern_clear;
 extern const cairo_private cairo_solid_pattern_t _cairo_pattern_black;
 extern const cairo_private cairo_solid_pattern_t _cairo_pattern_white;
 
-typedef struct _cairo_surface_attributes {
+struct _cairo_surface_attributes {
     cairo_matrix_t matrix;
     cairo_extend_t extend;
     cairo_filter_t filter;
@@ -984,7 +984,7 @@ typedef struct _cairo_surface_attributes {
     int		   x_offset;
     int		   y_offset;
     void	   *extra;
-} cairo_surface_attributes_t;
+};
 
 typedef struct _cairo_traps {
     cairo_status_t status;


More information about the cairo-commit mailing list