[cairo] Cairo and layered application

Chris Wilson ickle at chris-wilson.co.uk
Wed Mar 7 06:05:36 PST 2007


Following Behdad's call to arms, I added valgrind/callgrind targets to
perf/Makefile.am similar to test/Makefile.am.

This immediately showed that there were a couple of per-test leaks...

* crosses fingers and hopes he has submitted the patches in the approved
manner.
--
Chris Wilson
-------------- next part --------------
>From c7c068129c22048e9f068db47637446b1d995379 Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed, 7 Mar 2007 12:19:44 +0000
Subject: [PATCH] Add valgrind/callgrind targets to Makefile.
---
 perf/Makefile.am |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/perf/Makefile.am b/perf/Makefile.am
index a50ce8a..cef6431 100644
--- a/perf/Makefile.am
+++ b/perf/Makefile.am
@@ -60,5 +60,25 @@ LDADD = $(top_builddir)/boilerplate/libc
 perf: cairo-perf FORCE
 	./cairo-perf
 
+EXTRA_VG_FLAGS = $(CAIRO_EXTRA_VALGRIND_FLAGS)
+VG_MEMCHECK_FLAGS = \
+	--tool=memcheck \
+	--suppressions=$(top_srcdir)/test/.valgrind-suppressions \
+	--leak-check=yes --show-reachable=yes
+VG_CALLGRIND_FLAGS = \
+	--tool=callgrind
+CLEANFILES = \
+	valgrind-log
+
+perf-valgrind: cairo-perf FORCE
+	$(top_srcdir)/libtool --mode=execute \
+		valgrind $(VG_MEMCHECK_FLAGS) $(EXTRA_VG_FLAGS) \
+		./cairo-perf 2>&1 | tee valgrind-log
+perf-callgrind: cairo-perf FORCE
+	$(top_srcdir)/libtool --mode=execute \
+		valgrind $(VG_CALLGRIND_FLAGS) $(EXTRA_VG_FLAGS) \
+		./cairo-perf
+
 FORCE:
 
+.PHONY: perf perf-valgrind perf-callgrind FORCE
-- 
1.4.1

-------------- next part --------------
>From ddebb6a7d6b4205d554dadf740f3d596eff431e7 Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed, 7 Mar 2007 13:31:54 +0000
Subject: [PATCH] Fix up the trivial leaks found by valgrind.
---
 perf/cairo-perf.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c
index ae83690..49f4b59 100644
--- a/perf/cairo-perf.c
+++ b/perf/cairo-perf.c
@@ -185,6 +185,7 @@ cairo_perf_run (cairo_perf_t		*perf,
     }
 
     perf->test_number++;
+    free (times);
 }
 
 static void
@@ -307,6 +308,9 @@ main (int argc, char *argv[])
 
 		cairo_destroy (perf.cr);
 		cairo_surface_destroy (surface);
+
+		if (target->cleanup)
+		    target->cleanup (target->closure);
 	    }
 	}
     }
-- 
1.4.1



More information about the cairo mailing list