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

Carl Worth cworth at kemper.freedesktop.org
Tue Feb 6 21:19:37 PST 2007


 src/cairo-scaled-font.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

New commits:
diff-tree 97a2522e0bbe8464028b9b42c79e0b3559b532be (from 1503a41c7f115033b10470574027cffab0730687)
Author: Carl Worth <cworth at cworth.org>
Date:   Tue Feb 6 21:19:30 2007 -0800

    Add missing locking to _cairo_scaled_font_text_to_glyphs
    
    We recently added locking to cairo_scaled_font_glyph_extents and
    to _cairo_surface_show_glyphs, but we had neglected the third
    separate entry point into scaled_font code that does cache-using
    glyph lookups, namely: _cairo_scaled_font_text_to_glyphs.
    
    These three separate functions are plainly visible in the
    implementation of cairo_show_text.

diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 1ae7bfc..6c0455d 100755
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -801,6 +801,8 @@ _cairo_scaled_font_text_to_glyphs (cairo
 	return CAIRO_STATUS_SUCCESS;
     }
 
+    CAIRO_MUTEX_LOCK (scaled_font->mutex);
+
     if (scaled_font->backend->text_to_glyphs) {
 	status = scaled_font->backend->text_to_glyphs (scaled_font,
 						       x, y, utf8,
@@ -812,13 +814,13 @@ _cairo_scaled_font_text_to_glyphs (cairo
 
     status = _cairo_utf8_to_ucs4 ((unsigned char*)utf8, -1, &ucs4, num_glyphs);
     if (status)
-	return status;
+	goto DONE;
 
     *glyphs = (cairo_glyph_t *) malloc ((*num_glyphs) * (sizeof (cairo_glyph_t)));
 
     if (*glyphs == NULL) {
 	status = CAIRO_STATUS_NO_MEMORY;
-	goto FAIL;
+	goto DONE;
     }
 
     for (i = 0; i < *num_glyphs; i++) {
@@ -834,15 +836,18 @@ _cairo_scaled_font_text_to_glyphs (cairo
 	if (status) {
 	    free (*glyphs);
 	    *glyphs = NULL;
-	    goto FAIL;
+	    goto DONE;
 	}
 
         x += scaled_glyph->metrics.x_advance;
         y += scaled_glyph->metrics.y_advance;
     }
 
- FAIL:
-    free (ucs4);
+ DONE:
+    CAIRO_MUTEX_UNLOCK (scaled_font->mutex);
+
+    if (ucs4)
+	free (ucs4);
 
     return status;
 }


More information about the cairo-commit mailing list