[Pixman] [PATCH] Plug leak in the alphamap test.

Søren Sandmann sandmann at daimi.au.dk
Fri Oct 8 04:47:24 PDT 2010


From: Søren Sandmann Pedersen <ssp at redhat.com>

The images are being created with non-NULL data, so we have to free it
outselves. This is important because the Cygwin tinderbox is running
out of memory and produces this:

    mmap failed on 20000 1507328
    mmap failed on 40000 1507328
    mmap failed on 20000 1507328
    mmap failed on 40000 1507328
    mmap failed on 40000 1507328
    mmap failed on 40000 1507328

http://tinderbox.x.org/builds/2010-10-05-0014/logs/pixman/#check
---
 test/alphamap.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/test/alphamap.c b/test/alphamap.c
index 09de387..498fdab 100644
--- a/test/alphamap.c
+++ b/test/alphamap.c
@@ -45,15 +45,27 @@ format_name (pixman_format_code_t format)
     return "<unknown - bug in alphamap.c>";
 }
 
+static void
+on_destroy (pixman_image_t *image, void *data)
+{
+    uint32_t *bits = pixman_image_get_data (image);
+
+    fence_free (bits);
+}
+
 static pixman_image_t *
 make_image (pixman_format_code_t format)
 {
     uint32_t *bits;
     uint8_t bpp = PIXMAN_FORMAT_BPP (format) / 8;
+    pixman_image_t *image;
 
     bits = (uint32_t *)make_random_bytes (WIDTH * HEIGHT * bpp);
 
-    return pixman_image_create_bits (format, WIDTH, HEIGHT, bits, WIDTH * bpp);
+    image = pixman_image_create_bits (format, WIDTH, HEIGHT, bits, WIDTH * bpp);
+
+    if (image && bits)
+	pixman_image_set_destroy_function (image, on_destroy, NULL);
 }
 
 static pixman_image_t *
-- 
1.6.0.6



More information about the Pixman mailing list