[pango] Fix test leaks



commit 96f6c065deae8093f3c27e040ac1586de6113309
Author: Behdad Esfahbod <behdad behdad org>
Date:   Mon Jan 7 02:13:11 2013 -0600

    Fix test leaks
    
    Valgrinding....  Apparently somewhere some memory corruption happens.
    Argh...

 tests/test-pangocairo-threads.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/tests/test-pangocairo-threads.c b/tests/test-pangocairo-threads.c
index b33de73..520f7c3 100644
--- a/tests/test-pangocairo-threads.c
+++ b/tests/test-pangocairo-threads.c
@@ -58,6 +58,10 @@ thread_func (gpointer data)
   for (i = 0; i < num_iters; i++)
     draw (cr, layout, i);
 
+  g_object_unref (layout);
+
+  cairo_destroy (cr);
+
   return 0;
 }
 
@@ -92,6 +96,8 @@ main (int argc, char **argv)
   for (i = 0; i < num_threads; i++)
     g_thread_join (g_ptr_array_index (threads, i));
 
+  g_ptr_array_free (threads, TRUE);
+
   /* Now, draw a reference image and check results. */
   {
     cairo_surface_t *ref_surface = create_surface ();
@@ -102,6 +108,9 @@ main (int argc, char **argv)
 
     draw (cr, layout, num_iters - 1);
 
+    g_object_unref (layout);
+    cairo_destroy (cr);
+
     /* cairo_surface_write_to_png (ref_surface, "test-pangocairo-threads-reference.png"); */
 
     g_assert (WIDTH == cairo_format_stride_for_width (CAIRO_FORMAT_A8, WIDTH));
@@ -117,8 +126,15 @@ main (int argc, char **argv)
 	    cairo_surface_write_to_png (surface, "test-pangocairo-threads-failed.png");
 	    return 1;
 	  }
+	cairo_surface_destroy (surface);
       }
+
+    cairo_surface_destroy (ref_surface);
   }
 
+  g_ptr_array_free (surfaces, TRUE);
+
+  pango_cairo_font_map_set_default (NULL);
+
   return 0;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]