[cairo-commit] cairo/test cairo-test.c,1.38,1.39

Carl Worth commit at pdx.freedesktop.org
Thu Jul 14 11:11:17 PDT 2005


Committed by: cworth

Update of /cvs/cairo/cairo/test
In directory gabe:/tmp/cvs-serv7247/test

Modified Files:
	cairo-test.c 
Log Message:

        * test/cairo-test.c: (cleanup_xcb), (cleanup_xlib),
        (cairo_test_for_target), (cairo_test_real): Patch a few memory
        leaks.


Index: cairo-test.c
===================================================================
RCS file: /cvs/cairo/cairo/test/cairo-test.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- cairo-test.c	15 Jun 2005 17:58:52 -0000	1.38
+++ cairo-test.c	14 Jul 2005 18:11:15 -0000	1.39
@@ -338,6 +338,7 @@
 
     XCBFreePixmap (xtc->c, xtc->drawable.pixmap);
     XCBDisconnect (xtc->c);
+    free (xtc);
 }
 #endif
 
@@ -388,6 +389,7 @@
 
     XFreePixmap (xtc->dpy, xtc->pixmap);
     XCloseDisplay (xtc->dpy);
+    free (xtc);
 }
 #endif
 
@@ -401,7 +403,6 @@
     cairo_t *cr;
     char *png_name, *ref_name, *diff_name;
     char *srcdir;
-    int pixels_changed;
     cairo_test_status_t ret;
 
     /* Get the strings ready that we'll need. */
@@ -420,7 +421,8 @@
 					       &target->closure);
     if (surface == NULL) {
 	cairo_test_log ("Error: Failed to set %s target\n", target->name);
-	return CAIRO_TEST_FAILURE;
+	ret = CAIRO_TEST_FAILURE;
+	goto UNWIND_STRINGS;
     }
 
     cr = cairo_create (surface);
@@ -436,40 +438,42 @@
     /* Then, check all the different ways it could fail. */
     if (status) {
 	cairo_test_log ("Error: Function under test failed\n");
-	return status;
+	ret = status;
+	goto UNWIND_CAIRO;
     }
 
     if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
 	cairo_test_log ("Error: Function under test left cairo status in an error state: %s\n",
 			cairo_status_to_string (cairo_status (cr)));
-	return CAIRO_TEST_FAILURE;
+	ret = CAIRO_TEST_FAILURE;
+	goto UNWIND_CAIRO;
     }
 
+    if (test->width > 0 && test->height > 0)
+
+
     /* Skip image check for tests with no image (width,height == 0,0) */
-    if (test->width == 0 || test->height == 0) {
-	cairo_destroy (cr);
-	return CAIRO_TEST_SUCCESS;
+    if (test->width != 0 && test->height != 0) {
+	int pixels_changed;
+	cairo_surface_write_to_png (surface, png_name);
+	pixels_changed = image_diff (png_name, ref_name, diff_name);
+	if (pixels_changed) {
+	    if (pixels_changed > 0)
+		cairo_test_log ("Error: %d pixels differ from reference image %s\n",
+				pixels_changed, ref_name);
+	    ret = CAIRO_TEST_FAILURE;
+	    goto UNWIND_CAIRO;
+	}
     }
 
-    cairo_surface_write_to_png (surface, png_name);
+    ret = CAIRO_TEST_SUCCESS;
 
+UNWIND_CAIRO:
     cairo_destroy (cr);
-
     cairo_surface_destroy (surface);
-
     target->cleanup_target (target->closure);
 
-    pixels_changed = image_diff (png_name, ref_name, diff_name);
-
-    if (pixels_changed) {
-	ret = CAIRO_TEST_FAILURE;
-	if (pixels_changed > 0)
-	    cairo_test_log ("Error: %d pixels differ from reference image %s\n",
-		     pixels_changed, ref_name);
-    } else {
-	ret = CAIRO_TEST_SUCCESS;
-    }
-
+UNWIND_STRINGS:
     free (png_name);
     free (ref_name);
     free (diff_name);
@@ -511,6 +515,7 @@
 	fprintf (stderr, "Error opening log file: %s\n", log_name);
 	cairo_test_log_file = stderr;
     }
+    free (log_name);
 
     ret = CAIRO_TEST_SUCCESS;
     for (i=0; i < sizeof(targets)/sizeof(targets[0]); i++) {




More information about the cairo-commit mailing list