[cairo-commit] cairo/src cairo-scaled-font.c,1.5,1.6

Carl Worth commit at pdx.freedesktop.org
Tue Sep 13 12:40:38 PDT 2005


Committed by: cworth

Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv13678/src

Modified Files:
	cairo-scaled-font.c 
Log Message:

2005-09-13  Carl Worth  <cworth at cworth.org>

        * src/cairo-scaled-font.c: (_cairo_scaled_glyph_lookup): Add
        missing locking around the call into the thread-shared cache here.


Index: cairo-scaled-font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-scaled-font.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cairo-scaled-font.c	13 Sep 2005 19:26:30 -0000	1.5
+++ cairo-scaled-font.c	13 Sep 2005 19:40:36 -0000	1.6
@@ -1111,7 +1111,7 @@
 			    cairo_scaled_glyph_info_t info,
 			    cairo_scaled_glyph_t **scaled_glyph_ret)
 {
-    cairo_status_t		status;
+    cairo_status_t		status = CAIRO_STATUS_SUCCESS;
     cairo_cache_entry_t		key;
     cairo_scaled_glyph_t	*scaled_glyph;
     cairo_scaled_glyph_info_t	need_info;
@@ -1119,6 +1119,8 @@
     if (scaled_font->status)
 	return scaled_font->status;
 
+    CAIRO_MUTEX_LOCK (cairo_scaled_font_map_mutex);
+
     key.hash = index;
     /*
      * Check cache for glyph
@@ -1133,8 +1135,7 @@
 	scaled_glyph = malloc (sizeof (cairo_scaled_glyph_t));
 	if (scaled_glyph == NULL) {
 	    status = CAIRO_STATUS_NO_MEMORY;
-	    _cairo_scaled_font_set_error (scaled_font, status);
-	    return status;
+	    goto CLEANUP;
 	}
 	    
 	_cairo_scaled_glyph_set_index(scaled_glyph, index);
@@ -1147,18 +1148,13 @@
 	/* ask backend to initialize metrics and shape fields */
 	status = (*scaled_font->backend->
 		  scaled_glyph_init) (scaled_font, scaled_glyph, info);
-	if (status) {
-	    _cairo_scaled_glyph_destroy (scaled_glyph);
-	    _cairo_scaled_font_set_error (scaled_font, status);
-	    return status;
-	}
+	if (status)
+	    goto CLEANUP;
+
 	status = _cairo_cache_insert (scaled_font->glyphs,
 				      &scaled_glyph->cache_entry);
-	if (status) {
-	    _cairo_scaled_glyph_destroy (scaled_glyph);
-	    _cairo_scaled_font_set_error (scaled_font, status);
-	    return status;
-	}
+	if (status)
+	    goto CLEANUP;
     }
     /*
      * Check and see if the glyph, as provided,
@@ -1177,8 +1173,20 @@
 	status = (*scaled_font->backend->
 		  scaled_glyph_init) (scaled_font, scaled_glyph, need_info);
 	if (status)
-	    return status;
+	    goto CLEANUP;
     }
-    *scaled_glyph_ret = scaled_glyph;
-    return CAIRO_STATUS_SUCCESS;
+
+  CLEANUP:
+    if (status) {
+	_cairo_scaled_font_set_error (scaled_font, status);
+	if (scaled_glyph)
+	    _cairo_scaled_glyph_destroy (scaled_glyph);
+	*scaled_glyph_ret = NULL;
+    } else {
+	*scaled_glyph_ret = scaled_glyph;
+    }
+
+    CAIRO_MUTEX_UNLOCK (cairo_scaled_font_map_mutex);
+
+    return status;
 }



More information about the cairo-commit mailing list