[cairo-commit] cairo/src cairo_xlib_surface.c,1.7,1.8

Carl Worth commit at pdx.freedesktop.org
Thu Oct 30 18:39:23 PST 2003


Committed by: cworth

Update of /cvs/cairo/cairo/src
In directory pdx:/tmp/cvs-serv4777/src

Modified Files:
	cairo_xlib_surface.c 
Log Message:
Fixed a few memory leaks

Index: cairo_xlib_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_xlib_surface.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** cairo_xlib_surface.c	28 Oct 2003 20:18:29 -0000	1.7
--- cairo_xlib_surface.c	31 Oct 2003 02:39:21 -0000	1.8
***************
*** 150,153 ****
--- 150,161 ----
  	XFreePixmap (surface->dpy, surface->drawable);
  
+     if (surface->ximage) {
+ 	surface->ximage->data = NULL;
+ 	XDestroyImage(surface->ximage);
+     }
+ 
+     if (surface->gc)
+ 	XFreeGC (surface->dpy, surface->gc);
+ 
      surface->dpy = 0;
  }
***************
*** 391,394 ****
--- 399,405 ----
      cairo_xlib_surface_t *src = (cairo_xlib_surface_t *) generic_src;
      cairo_xlib_surface_t *mask = (cairo_xlib_surface_t *) generic_mask;
+     cairo_xlib_surface_t *src_clone = NULL;
+     cairo_xlib_surface_t *mask_clone = NULL;
+     
  
      if (!CAIRO_SURFACE_RENDER_HAS_COMPOSITE (dst))
***************
*** 396,407 ****
  
      if (generic_src->backend != dst->base.backend || src->dpy != dst->dpy) {
! 	src = _cairo_xlib_surface_clone_from (generic_src, dst, CAIRO_FORMAT_ARGB32, 32);
! 	if (!src)
  	    return CAIRO_INT_STATUS_UNSUPPORTED;
      }
      if (generic_mask && (generic_mask->backend != dst->base.backend || mask->dpy != dst->dpy)) {
! 	mask = _cairo_xlib_surface_clone_from (generic_mask, dst, CAIRO_FORMAT_A8, 8);
! 	if (!mask)
  	    return CAIRO_INT_STATUS_UNSUPPORTED;
      }
  
--- 407,420 ----
  
      if (generic_src->backend != dst->base.backend || src->dpy != dst->dpy) {
! 	src_clone = _cairo_xlib_surface_clone_from (generic_src, dst, CAIRO_FORMAT_ARGB32, 32);
! 	if (!src_clone)
  	    return CAIRO_INT_STATUS_UNSUPPORTED;
+ 	src = src_clone;
      }
      if (generic_mask && (generic_mask->backend != dst->base.backend || mask->dpy != dst->dpy)) {
! 	mask_clone = _cairo_xlib_surface_clone_from (generic_mask, dst, CAIRO_FORMAT_A8, 8);
! 	if (!mask_clone)
  	    return CAIRO_INT_STATUS_UNSUPPORTED;
+ 	mask = mask_clone;
      }
  
***************
*** 415,418 ****
--- 428,438 ----
  		      width, height);
  
+     /* XXX: This is messed up. If I can xlib_surface_create, then I
+        should be able to xlib_surface_destroy. */
+     if (src_clone)
+ 	cairo_surface_destroy (&src_clone->base);
+     if (mask_clone)
+ 	cairo_surface_destroy (&mask_clone->base);
+ 
      return CAIRO_STATUS_SUCCESS;
  }
***************
*** 454,464 ****
      cairo_xlib_surface_t *dst = abstract_dst;
      cairo_xlib_surface_t *src = (cairo_xlib_surface_t *) generic_src;
      if (!CAIRO_SURFACE_RENDER_HAS_TRAPEZOIDS (dst))
  	return CAIRO_INT_STATUS_UNSUPPORTED;
  
      if (generic_src->backend != dst->base.backend || src->dpy != dst->dpy) {
! 	src = _cairo_xlib_surface_clone_from (generic_src, dst, CAIRO_FORMAT_ARGB32, 32);
! 	if (!src)
  	    return CAIRO_INT_STATUS_UNSUPPORTED;
      }
  
--- 474,487 ----
      cairo_xlib_surface_t *dst = abstract_dst;
      cairo_xlib_surface_t *src = (cairo_xlib_surface_t *) generic_src;
+     cairo_xlib_surface_t *src_clone = NULL;
+ 
      if (!CAIRO_SURFACE_RENDER_HAS_TRAPEZOIDS (dst))
  	return CAIRO_INT_STATUS_UNSUPPORTED;
  
      if (generic_src->backend != dst->base.backend || src->dpy != dst->dpy) {
! 	src_clone = _cairo_xlib_surface_clone_from (generic_src, dst, CAIRO_FORMAT_ARGB32, 32);
! 	if (!src_clone)
  	    return CAIRO_INT_STATUS_UNSUPPORTED;
+ 	src = src_clone;
      }
  
***************
*** 468,471 ****
--- 491,499 ----
  				xSrc, ySrc, (XTrapezoid *) traps, num_traps);
  
+     /* XXX: This is messed up. If I can xlib_surface_create, then I
+        should be able to xlib_surface_destroy. */
+     if (src_clone)
+ 	cairo_surface_destroy (&src_clone->base);
+ 
      return CAIRO_STATUS_SUCCESS;
  }





More information about the cairo-commit mailing list