[cairo-commit] perf/cairo-perf.c

Chris Wilson ickle at kemper.freedesktop.org
Mon Apr 30 08:06:48 PDT 2007


 perf/cairo-perf.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+)

New commits:
diff-tree a5d1fc923fdef354ceed8478c93e8b7cb734158a (from 7e6ab5461c2eb75c948bcb4725613ebe826c697a)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Apr 30 16:05:36 2007 +0100

    Free all memory when cairo-perf exits.
    
    Similar to cairo-test, we free any global memory used by cairo for its
    caches through the debug interfaces. We do this so that valgrind does
    not unnecessary warn about memory leaks for the cached data and any true
    leak is then not lost in the noise.

diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c
index 1363f89..af06bb6 100644
--- a/perf/cairo-perf.c
+++ b/perf/cairo-perf.c
@@ -34,6 +34,10 @@
 /* For basename */
 #include <libgen.h>
 
+#if HAVE_FCFINI
+#include <fontconfig/fontconfig.h>
+#endif
+
 #ifdef HAVE_SCHED_H
 #include <sched.h>
 #endif
@@ -299,6 +303,16 @@ check_cpu_affinity(void)
 #endif
 }
 
+static void
+cairo_perf_fini (void)
+{
+    cairo_debug_reset_static_data ();
+#if HAVE_FCFINI
+    FcFini ();
+#endif
+}
+
+
 int
 main (int argc, char *argv[])
 {
@@ -351,6 +365,8 @@ main (int argc, char *argv[])
 		    fprintf (stderr,
 			     "Error: Failed to create target surface: %s\n",
 			     target->name);
+		    cairo_boilerplate_free_targets (targets);
+		    cairo_perf_fini ();
 		    exit (1);
 		}
 
@@ -364,6 +380,8 @@ main (int argc, char *argv[])
 		if (cairo_status (perf.cr)) {
 		    fprintf (stderr, "Error: Test left cairo in an error state: %s\n",
 			     cairo_status_to_string (cairo_status (perf.cr)));
+		    cairo_boilerplate_free_targets (targets);
+		    cairo_perf_fini ();
 		    exit (1);
 		}
 
@@ -377,6 +395,7 @@ main (int argc, char *argv[])
     }
 
     cairo_boilerplate_free_targets (targets);
+    cairo_perf_fini ();
 
     return 0;
 }


More information about the cairo-commit mailing list