glamor: replace xallocarray() by calloc()
Only key difference that calloc(), in contrast to rellocarray(), is zero-initializing. The overhead is hard to measure on today's machines, and it's safer programming practise to always allocate zero-initialized, so one can't forget to do it explicitly. Cocci rule: @@ expression COUNT; expression LEN; @@ - xallocarray(COUNT,LEN) + calloc(COUNT,LEN) Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
e25852fd53
commit
7752d8450d
|
@ -58,7 +58,7 @@ _pixman_region_init_clipped_rectangles(pixman_region16_t * region,
|
|||
unsigned int i, j;
|
||||
|
||||
if (num_rects > ARRAY_SIZE(stack_boxes)) {
|
||||
boxes = xallocarray(num_rects, sizeof(pixman_box16_t));
|
||||
boxes = calloc(num_rects, sizeof(pixman_box16_t));
|
||||
if (boxes == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -990,13 +990,13 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
|
|||
|
||||
/* Set all the stops and colors to shader. */
|
||||
if (stops_count > RADIAL_SMALL_STOPS) {
|
||||
stop_colors = xallocarray(stops_count, 4 * sizeof(float));
|
||||
stop_colors = calloc(stops_count, 4 * sizeof(float));
|
||||
if (stop_colors == NULL) {
|
||||
ErrorF("Failed to allocate stop_colors memory.\n");
|
||||
goto GRADIENT_FAIL;
|
||||
}
|
||||
|
||||
n_stops = xallocarray(stops_count, sizeof(float));
|
||||
n_stops = calloc(stops_count, sizeof(float));
|
||||
if (n_stops == NULL) {
|
||||
ErrorF("Failed to allocate n_stops memory.\n");
|
||||
goto GRADIENT_FAIL;
|
||||
|
@ -1328,13 +1328,13 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
|
|||
|
||||
/* Set all the stops and colors to shader. */
|
||||
if (stops_count > LINEAR_SMALL_STOPS) {
|
||||
stop_colors = xallocarray(stops_count, 4 * sizeof(float));
|
||||
stop_colors = calloc(stops_count, 4 * sizeof(float));
|
||||
if (stop_colors == NULL) {
|
||||
ErrorF("Failed to allocate stop_colors memory.\n");
|
||||
goto GRADIENT_FAIL;
|
||||
}
|
||||
|
||||
n_stops = xallocarray(stops_count, sizeof(float));
|
||||
n_stops = calloc(stops_count, sizeof(float));
|
||||
if (n_stops == NULL) {
|
||||
ErrorF("Failed to allocate n_stops memory.\n");
|
||||
goto GRADIENT_FAIL;
|
||||
|
|
|
@ -123,8 +123,8 @@ glamor_prep_drawable_box(DrawablePtr drawable, glamor_access_t access, BoxPtr bo
|
|||
}
|
||||
|
||||
if (!priv->pbo) {
|
||||
pixmap->devPrivate.ptr = xallocarray(pixmap->devKind,
|
||||
pixmap->drawable.height);
|
||||
pixmap->devPrivate.ptr = calloc(pixmap->devKind,
|
||||
pixmap->drawable.height);
|
||||
if (!pixmap->devPrivate.ptr)
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ glamor_solid_boxes(DrawablePtr drawable,
|
|||
xRectangle *rect;
|
||||
int n;
|
||||
|
||||
rect = xallocarray(nbox, sizeof(xRectangle));
|
||||
rect = calloc(nbox, sizeof(xRectangle));
|
||||
if (!rect)
|
||||
return;
|
||||
for (n = 0; n < nbox; n++) {
|
||||
|
|
Loading…
Reference in New Issue