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;
|
unsigned int i, j;
|
||||||
|
|
||||||
if (num_rects > ARRAY_SIZE(stack_boxes)) {
|
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)
|
if (boxes == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -990,13 +990,13 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
|
||||||
|
|
||||||
/* Set all the stops and colors to shader. */
|
/* Set all the stops and colors to shader. */
|
||||||
if (stops_count > RADIAL_SMALL_STOPS) {
|
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) {
|
if (stop_colors == NULL) {
|
||||||
ErrorF("Failed to allocate stop_colors memory.\n");
|
ErrorF("Failed to allocate stop_colors memory.\n");
|
||||||
goto GRADIENT_FAIL;
|
goto GRADIENT_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
n_stops = xallocarray(stops_count, sizeof(float));
|
n_stops = calloc(stops_count, sizeof(float));
|
||||||
if (n_stops == NULL) {
|
if (n_stops == NULL) {
|
||||||
ErrorF("Failed to allocate n_stops memory.\n");
|
ErrorF("Failed to allocate n_stops memory.\n");
|
||||||
goto GRADIENT_FAIL;
|
goto GRADIENT_FAIL;
|
||||||
|
@ -1328,13 +1328,13 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
|
||||||
|
|
||||||
/* Set all the stops and colors to shader. */
|
/* Set all the stops and colors to shader. */
|
||||||
if (stops_count > LINEAR_SMALL_STOPS) {
|
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) {
|
if (stop_colors == NULL) {
|
||||||
ErrorF("Failed to allocate stop_colors memory.\n");
|
ErrorF("Failed to allocate stop_colors memory.\n");
|
||||||
goto GRADIENT_FAIL;
|
goto GRADIENT_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
n_stops = xallocarray(stops_count, sizeof(float));
|
n_stops = calloc(stops_count, sizeof(float));
|
||||||
if (n_stops == NULL) {
|
if (n_stops == NULL) {
|
||||||
ErrorF("Failed to allocate n_stops memory.\n");
|
ErrorF("Failed to allocate n_stops memory.\n");
|
||||||
goto GRADIENT_FAIL;
|
goto GRADIENT_FAIL;
|
||||||
|
|
|
@ -123,7 +123,7 @@ glamor_prep_drawable_box(DrawablePtr drawable, glamor_access_t access, BoxPtr bo
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!priv->pbo) {
|
if (!priv->pbo) {
|
||||||
pixmap->devPrivate.ptr = xallocarray(pixmap->devKind,
|
pixmap->devPrivate.ptr = calloc(pixmap->devKind,
|
||||||
pixmap->drawable.height);
|
pixmap->drawable.height);
|
||||||
if (!pixmap->devPrivate.ptr)
|
if (!pixmap->devPrivate.ptr)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -31,7 +31,7 @@ glamor_solid_boxes(DrawablePtr drawable,
|
||||||
xRectangle *rect;
|
xRectangle *rect;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
rect = xallocarray(nbox, sizeof(xRectangle));
|
rect = calloc(nbox, sizeof(xRectangle));
|
||||||
if (!rect)
|
if (!rect)
|
||||||
return;
|
return;
|
||||||
for (n = 0; n < nbox; n++) {
|
for (n = 0; n < nbox; n++) {
|
||||||
|
|
Loading…
Reference in New Issue