diff options
author | Uli Schlachter <psychon@znc.in> | 2018-01-13 11:34:19 +0100 |
---|---|---|
committer | Uli Schlachter <psychon@znc.in> | 2018-03-15 21:43:03 +0100 |
commit | 1ed124ace201946177eab962d3b07bb2fedf9026 (patch) | |
tree | e3be7660cb24f7088f64071122d8864de9ef0120 /src | |
parent | 5454b85d4bf2f7bea454c940d90255a15517fa3b (diff) | |
download | cairo-1ed124ace201946177eab962d3b07bb2fedf9026.tar.gz |
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@znc.in>
Diffstat (limited to 'src')
-rw-r--r-- | src/cairo-debug.c | 2 | ||||
-rw-r--r-- | src/cairo-image-compositor.c | 17 | ||||
-rw-r--r-- | src/cairoint.h | 3 |
3 files changed, 22 insertions, 0 deletions
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, |