[cairo-commit] pixman/src src/cairo-glitz-surface.c

Christian Biesinger biesi at kemper.freedesktop.org
Wed Apr 19 01:32:07 EEST 2006


 pixman/src/icpixels.c     |    3 +--
 pixman/src/ictrap.c       |    6 +-----
 src/cairo-glitz-surface.c |    4 +---
 3 files changed, 3 insertions(+), 10 deletions(-)

New commits:
diff-tree efbe40bb8f770fbf60de794488803d3edacd7ed6 (from eadb26a1c13da1af292f0262e108878133cbadf0)
Author: Christian Biesinger <cbiesinger at web.de>
Date:   Wed Apr 19 00:29:48 2006 +0200

    Use calloc rather than malloc+memset

diff --git a/pixman/src/icpixels.c b/pixman/src/icpixels.c
index 2ad34f4..c5efae9 100644
--- a/pixman/src/icpixels.c
+++ b/pixman/src/icpixels.c
@@ -65,12 +65,11 @@ FbPixelsCreate (int width, int height, i
 	adjust = 8 - (base & 7);
     buf_size += adjust;
 
-    pixels = malloc(base + buf_size);
+    pixels = calloc(base + buf_size, 1);
     if (!pixels)
 	return NULL;
 
     buf = (pixman_bits_t *) ((char *)pixels + base + adjust);
-    memset (buf, 0, height * stride);
 
     FbPixelsInit (pixels, buf, width, height, depth, bpp, stride);
 
diff --git a/pixman/src/ictrap.c b/pixman/src/ictrap.c
index 08bd024..72616f3 100644
--- a/pixman/src/ictrap.c
+++ b/pixman/src/ictrap.c
@@ -45,16 +45,12 @@ FbCreateAlphaPicture (pixman_image_t	*ds
 	    return NULL;
     }
 
+    /* pixman_image_create zeroes out the pixels, so we don't have to */
     image = pixman_image_create (format, width, height); 
 
     if (own_format)
 	pixman_format_destroy (format);
 
-    /* XXX: Is this a reasonable way to clear the image? Would
-       probably be preferable to use pixman_image_fill_rectangle once such a
-       beast exists. */
-    memset (image->pixels->data, 0, height * image->pixels->stride);
-
     return image;
 }
 
diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
index c000917..ab2d6eb 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -1140,7 +1140,7 @@ _cairo_glitz_surface_composite_trapezoid
 	int		      stride;
 
 	stride = (width + 3) & -4;
-	data = malloc (stride * height);
+	data = calloc (stride * height, 1);
 	if (!data)
 	{
 	    _cairo_glitz_pattern_release_surface (src_pattern, src, &attributes);
@@ -1149,8 +1149,6 @@ _cairo_glitz_surface_composite_trapezoid
 	    return CAIRO_STATUS_NO_MEMORY;
 	}
 
-	memset (data, 0, stride * height);
-
 	/* using negative stride */
 	ptr = (unsigned char *) data + stride * (height - 1);
 


More information about the cairo-commit mailing list