[cairo-commit] src/cairo-debug.c src/cairo-image-compositor.c src/cairoint.h

Uli Schlachter psychon at kemper.freedesktop.org
Thu Mar 15 20:43:17 UTC 2018


 src/cairo-debug.c            |    2 ++
 src/cairo-image-compositor.c |   17 +++++++++++++++++
 src/cairoint.h               |    3 +++
 3 files changed, 22 insertions(+)

New commits:
commit 1ed124ace201946177eab962d3b07bb2fedf9026
Author: Uli Schlachter <psychon at znc.in>
Date:   Sat Jan 13 11:34:19 2018 +0100

    Fix a 'memory leak' in the image compositor
    
    There is a global pixman_glyph_cache_t instance that is initialized on
    first use and shows up in valgrind output as a relatively large leak (I
    think it was about 200 KiB). The reason for this is that this cache is
    not freed by cairo_debug_reset_static_data().
    
    This commit wires up freeing the cache to
    cairo_debug_reset_static_data().
    
    This cache was introduced in commit 615205cf0729 from 2012.
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-debug.c b/src/cairo-debug.c
index 10933a673..6005060d4 100644
--- a/src/cairo-debug.c
+++ b/src/cairo-debug.c
@@ -86,6 +86,8 @@ cairo_debug_reset_static_data (void)
 
     _cairo_image_reset_static_data ();
 
+    _cairo_image_compositor_reset_static_data ();
+
 #if CAIRO_HAS_DRM_SURFACE
     _cairo_drm_device_reset_static_data ();
 #endif
diff --git a/src/cairo-image-compositor.c b/src/cairo-image-compositor.c
index 9f4e0adad..122a8ca42 100644
--- a/src/cairo-image-compositor.c
+++ b/src/cairo-image-compositor.c
@@ -821,6 +821,18 @@ get_glyph_cache (void)
 }
 
 void
+_cairo_image_compositor_reset_static_data (void)
+{
+    CAIRO_MUTEX_LOCK (_cairo_glyph_cache_mutex);
+
+    if (global_glyph_cache)
+	pixman_glyph_cache_destroy (global_glyph_cache);
+    global_glyph_cache = NULL;
+
+    CAIRO_MUTEX_UNLOCK (_cairo_glyph_cache_mutex);
+}
+
+void
 _cairo_image_scaled_glyph_fini (cairo_scaled_font_t *scaled_font,
 				cairo_scaled_glyph_t *scaled_glyph)
 {
@@ -946,6 +958,11 @@ out_unlock:
 }
 #else
 void
+_cairo_image_compositor_reset_static_data (void)
+{
+}
+
+void
 _cairo_image_scaled_glyph_fini (cairo_scaled_font_t *scaled_font,
 				cairo_scaled_glyph_t *scaled_glyph)
 {
diff --git a/src/cairoint.h b/src/cairoint.h
index 051e4f805..11f2c1eaf 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1586,6 +1586,9 @@ _cairo_image_scaled_glyph_fini (cairo_scaled_font_t *scaled_font,
 cairo_private void
 _cairo_image_reset_static_data (void);
 
+cairo_private void
+_cairo_image_compositor_reset_static_data (void);
+
 cairo_private cairo_surface_t *
 _cairo_image_surface_create_with_pixman_format (unsigned char		*data,
 						pixman_format_code_t	 pixman_format,


More information about the cairo-commit mailing list