[PATCH] [cairo-font-face] Use cairo_font_face_status() in preference to open-coding.

Chris Wilson chris at chris-wilson.co.uk
Fri Feb 22 11:47:35 PST 2008


Use cairo_font_face_status() in guards in preference over font_face->status.
---
 src/cairo-font-face.c |   35 ++++++++++++++++++++++++-----------
 1 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/src/cairo-font-face.c b/src/cairo-font-face.c
index 2077120..04de9dd 100644
--- a/src/cairo-font-face.c
+++ b/src/cairo-font-face.c
@@ -98,8 +98,10 @@ cairo_font_face_t *
 cairo_font_face_reference (cairo_font_face_t *font_face)
 {
     if (font_face == NULL ||
-	    CAIRO_REFERENCE_COUNT_IS_INVALID (&font_face->ref_count))
+	CAIRO_REFERENCE_COUNT_IS_INVALID (&font_face->ref_count))
+    {
 	return font_face;
+    }
 
     /* We would normally assert that we have a reference here but we
      * can't get away with that due to the zombie case as documented
@@ -123,8 +125,10 @@ void
 cairo_font_face_destroy (cairo_font_face_t *font_face)
 {
     if (font_face == NULL ||
-	    CAIRO_REFERENCE_COUNT_IS_INVALID (&font_face->ref_count))
+	CAIRO_REFERENCE_COUNT_IS_INVALID (&font_face->ref_count))
+    {
 	return;
+    }
 
     assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&font_face->ref_count));
 
@@ -160,6 +164,9 @@ slim_hidden_def (cairo_font_face_destroy);
 cairo_font_type_t
 cairo_font_face_get_type (cairo_font_face_t *font_face)
 {
+    if (cairo_font_face_status (font_face))
+	return CAIRO_FONT_TYPE_TOY;
+
     return font_face->backend->type;
 }
 
@@ -178,8 +185,10 @@ unsigned int
 cairo_font_face_get_reference_count (cairo_font_face_t *font_face)
 {
     if (font_face == NULL ||
-	    CAIRO_REFERENCE_COUNT_IS_INVALID (&font_face->ref_count))
+	CAIRO_REFERENCE_COUNT_IS_INVALID (&font_face->ref_count))
+    {
 	return 0;
+    }
 
     return CAIRO_REFERENCE_COUNT_GET_VALUE (&font_face->ref_count);
 }
@@ -197,6 +206,9 @@ cairo_font_face_get_reference_count (cairo_font_face_t *font_face)
 cairo_status_t
 cairo_font_face_status (cairo_font_face_t *font_face)
 {
+    if (font_face == NULL)
+	return CAIRO_STATUS_NULL_POINTER;
+
     return font_face->status;
 }
 
@@ -216,8 +228,7 @@ void *
 cairo_font_face_get_user_data (cairo_font_face_t	   *font_face,
 			       const cairo_user_data_key_t *key)
 {
-    return _cairo_user_data_array_get_data (&font_face->user_data,
-					    key);
+    return _cairo_user_data_array_get_data (&font_face->user_data, key);
 }
 
 /**
@@ -272,8 +283,7 @@ _cairo_toy_font_face_hash_table_lock (void)
 {
     CAIRO_MUTEX_LOCK (_cairo_font_face_mutex);
 
-    if (cairo_toy_font_face_hash_table == NULL)
-    {
+    if (cairo_toy_font_face_hash_table == NULL) {
 	cairo_toy_font_face_hash_table =
 	    _cairo_hash_table_create (_cairo_toy_font_face_keys_equal);
 
@@ -399,7 +409,7 @@ _cairo_toy_font_face_create (const char          *family,
 				  &key.base.hash_entry,
 				  (cairo_hash_entry_t **) &font_face))
     {
-	if (! font_face->base.status)  {
+	if (font_face->base.status == CAIRO_STATUS_SUCCESS)  {
 	    /* We increment the reference count here manually to avoid
 	       double-locking. */
 	    _cairo_reference_count_inc (&font_face->base.ref_count);
@@ -447,8 +457,10 @@ _cairo_toy_font_face_destroy (void *abstract_face)
     cairo_hash_table_t *hash_table;
 
     if (font_face == NULL ||
-	    CAIRO_REFERENCE_COUNT_IS_INVALID (&font_face->base.ref_count))
+	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. */
@@ -473,8 +485,9 @@ _cairo_toy_font_face_scaled_font_create (void                *abstract_font_face
     const cairo_scaled_font_backend_t * backend = CAIRO_SCALED_FONT_BACKEND_DEFAULT;
     cairo_status_t status;
 
-    if (font_face->base.status)
-	return font_face->base.status;
+    status = cairo_font_face_status (abstract_font_face);
+    if (status)
+	return status;
 
     status = cairo_font_options_status ((cairo_font_options_t *) options);
     if (status)
-- 
1.5.3.8


--=-BzpsUfdHqkE+TbB0ojYn
Content-Disposition: attachment; filename=0056-cairo-image-surface-Use-cairo_surface_status-gua.patch
Content-Type: application/mbox; name=0056-cairo-image-surface-Use-cairo_surface_status-gua.patch
Content-Transfer-Encoding: 7bit



More information about the cairo mailing list