mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 18:08:03 +02:00
Use calloc rather than malloc+memset
This commit is contained in:
parent
eadb26a1c1
commit
efbe40bb8f
3 changed files with 3 additions and 10 deletions
|
|
@ -65,12 +65,11 @@ FbPixelsCreate (int width, int height, int depth)
|
|||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -45,16 +45,12 @@ FbCreateAlphaPicture (pixman_image_t *dst,
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1140,7 +1140,7 @@ _cairo_glitz_surface_composite_trapezoids (cairo_operator_t op,
|
|||
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_trapezoids (cairo_operator_t op,
|
|||
return CAIRO_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
memset (data, 0, stride * height);
|
||||
|
||||
/* using negative stride */
|
||||
ptr = (unsigned char *) data + stride * (height - 1);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue