[cairo-commit] src/cairo.c src/cairo-font.c src/cairo-pattern.c src/cairo-scaled-font.c src/cairo-surface.c

Behdad Esfahbod behdad at kemper.freedesktop.org
Mon Mar 5 13:28:25 PST 2007


 src/cairo-font.c        |   12 +++---------
 src/cairo-pattern.c     |   12 +++---------
 src/cairo-scaled-font.c |   12 +++---------
 src/cairo-surface.c     |   12 +++---------
 src/cairo.c             |   12 +++---------
 5 files changed, 15 insertions(+), 45 deletions(-)

New commits:
diff-tree 4f138e4af56da60a83fd187f87cde19544ba3ab1 (from cc12c5acc41f452edff3f4ad8fafe1aebf1810aa)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Mar 5 16:28:31 2007 -0500

    Uniform object handling in _reference(), _destroy(), and _get_reference_count()
    
    All three now regard NULL and nil inputs the same.  This is new for
    _get_reference_count().  It now returns 0 on NULL too, like it does on
    nil objects.

diff --git a/src/cairo-font.c b/src/cairo-font.c
index 3f96e3b..cacc589 100644
--- a/src/cairo-font.c
+++ b/src/cairo-font.c
@@ -87,10 +87,7 @@ CAIRO_MUTEX_DECLARE (_cairo_font_face_mu
 cairo_font_face_t *
 cairo_font_face_reference (cairo_font_face_t *font_face)
 {
-    if (font_face == NULL)
-	return NULL;
-
-    if (font_face->ref_count == CAIRO_REF_COUNT_INVALID)
+    if (font_face == NULL || font_face->ref_count == CAIRO_REF_COUNT_INVALID)
 	return font_face;
 
     CAIRO_MUTEX_LOCK (_cairo_font_face_mutex);
@@ -118,10 +115,7 @@ slim_hidden_def (cairo_font_face_referen
 void
 cairo_font_face_destroy (cairo_font_face_t *font_face)
 {
-    if (font_face == NULL)
-	return;
-
-    if (font_face->ref_count == CAIRO_REF_COUNT_INVALID)
+    if (font_face == NULL || font_face->ref_count == CAIRO_REF_COUNT_INVALID)
 	return;
 
     CAIRO_MUTEX_LOCK (_cairo_font_face_mutex);
@@ -181,7 +175,7 @@ cairo_font_face_get_type (cairo_font_fac
 unsigned int
 cairo_font_face_get_reference_count (cairo_font_face_t *font_face)
 {
-    if (font_face->ref_count == CAIRO_REF_COUNT_INVALID)
+    if (font_face == NULL || font_face->ref_count == CAIRO_REF_COUNT_INVALID)
 	return 0;
 
     return font_face->ref_count;
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index a17107c..efa0c5a 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -504,10 +504,7 @@ cairo_pattern_create_radial (double cx0,
 cairo_pattern_t *
 cairo_pattern_reference (cairo_pattern_t *pattern)
 {
-    if (pattern == NULL)
-	return NULL;
-
-    if (pattern->ref_count == CAIRO_REF_COUNT_INVALID)
+    if (pattern == NULL || pattern->ref_count == CAIRO_REF_COUNT_INVALID)
 	return pattern;
 
     assert (pattern->ref_count > 0);
@@ -564,10 +561,7 @@ slim_hidden_def (cairo_pattern_status);
 void
 cairo_pattern_destroy (cairo_pattern_t *pattern)
 {
-    if (pattern == NULL)
-	return;
-
-    if (pattern->ref_count == CAIRO_REF_COUNT_INVALID)
+    if (pattern == NULL || pattern->ref_count == CAIRO_REF_COUNT_INVALID)
 	return;
 
     assert (pattern->ref_count > 0);
@@ -595,7 +589,7 @@ slim_hidden_def (cairo_pattern_destroy);
 unsigned int
 cairo_pattern_get_reference_count (cairo_pattern_t *pattern)
 {
-    if (pattern->ref_count == CAIRO_REF_COUNT_INVALID)
+    if (pattern == NULL || pattern->ref_count == CAIRO_REF_COUNT_INVALID)
 	return 0;
 
     return pattern->ref_count;
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 957edbb..0162a0d 100755
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -544,10 +544,7 @@ slim_hidden_def (cairo_scaled_font_creat
 cairo_scaled_font_t *
 cairo_scaled_font_reference (cairo_scaled_font_t *scaled_font)
 {
-    if (scaled_font == NULL)
-	return NULL;
-
-    if (scaled_font->ref_count == CAIRO_REF_COUNT_INVALID)
+    if (scaled_font == NULL || scaled_font->ref_count == CAIRO_REF_COUNT_INVALID)
 	return scaled_font;
 
     _cairo_scaled_font_map_lock ();
@@ -576,10 +573,7 @@ cairo_scaled_font_destroy (cairo_scaled_
     cairo_scaled_font_map_t *font_map;
     cairo_scaled_font_t *lru = NULL;
 
-    if (scaled_font == NULL)
-	return;
-
-    if (scaled_font->ref_count == CAIRO_REF_COUNT_INVALID)
+    if (scaled_font == NULL || scaled_font->ref_count == CAIRO_REF_COUNT_INVALID)
 	return;
 
     font_map = _cairo_scaled_font_map_lock ();
@@ -641,7 +635,7 @@ slim_hidden_def (cairo_scaled_font_destr
 unsigned int
 cairo_scaled_font_get_reference_count (cairo_scaled_font_t *scaled_font)
 {
-    if (scaled_font->ref_count == CAIRO_REF_COUNT_INVALID)
+    if (scaled_font == NULL || scaled_font->ref_count == CAIRO_REF_COUNT_INVALID)
 	return 0;
 
     return scaled_font->ref_count;
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 1f5de8f..3162a01 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -357,10 +357,7 @@ _cairo_surface_get_clip_mode (cairo_surf
 cairo_surface_t *
 cairo_surface_reference (cairo_surface_t *surface)
 {
-    if (surface == NULL)
-	return NULL;
-
-    if (surface->ref_count == CAIRO_REF_COUNT_INVALID)
+    if (surface == NULL || surface->ref_count == CAIRO_REF_COUNT_INVALID)
 	return surface;
 
     assert (surface->ref_count > 0);
@@ -382,10 +379,7 @@ slim_hidden_def (cairo_surface_reference
 void
 cairo_surface_destroy (cairo_surface_t *surface)
 {
-    if (surface == NULL)
-	return;
-
-    if (surface->ref_count == CAIRO_REF_COUNT_INVALID)
+    if (surface == NULL || surface->ref_count == CAIRO_REF_COUNT_INVALID)
 	return;
 
     assert (surface->ref_count > 0);
@@ -417,7 +411,7 @@ slim_hidden_def(cairo_surface_destroy);
 unsigned int
 cairo_surface_get_reference_count (cairo_surface_t *surface)
 {
-    if (surface->ref_count == CAIRO_REF_COUNT_INVALID)
+    if (surface == NULL || surface->ref_count == CAIRO_REF_COUNT_INVALID)
 	return 0;
 
     return surface->ref_count;
diff --git a/src/cairo.c b/src/cairo.c
index 66434d0..de3eb74 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -230,10 +230,7 @@ slim_hidden_def (cairo_create);
 cairo_t *
 cairo_reference (cairo_t *cr)
 {
-    if (cr == NULL)
-	return NULL;
-
-    if (cr->ref_count == CAIRO_REF_COUNT_INVALID)
+    if (cr == NULL || cr->ref_count == CAIRO_REF_COUNT_INVALID)
 	return cr;
 
     assert (cr->ref_count > 0);
@@ -254,10 +251,7 @@ cairo_reference (cairo_t *cr)
 void
 cairo_destroy (cairo_t *cr)
 {
-    if (cr == NULL)
-	return;
-
-    if (cr->ref_count == CAIRO_REF_COUNT_INVALID)
+    if (cr == NULL || cr->ref_count == CAIRO_REF_COUNT_INVALID)
 	return;
 
     assert (cr->ref_count > 0);
@@ -348,7 +342,7 @@ cairo_set_user_data (cairo_t			 *cr,
 unsigned int
 cairo_get_reference_count (cairo_t *cr)
 {
-    if (cr->ref_count == CAIRO_REF_COUNT_INVALID)
+    if (cr == NULL || cr->ref_count == CAIRO_REF_COUNT_INVALID)
 	return 0;
 
     return cr->ref_count;


More information about the cairo-commit mailing list