kdrive: 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
11f9b11757
commit
5a003a7663
|
@ -939,7 +939,7 @@ hostx_screen_init(KdScreenInfo *screen,
|
||||||
scrpriv->ximg->byte_order = IMAGE_BYTE_ORDER;
|
scrpriv->ximg->byte_order = IMAGE_BYTE_ORDER;
|
||||||
|
|
||||||
scrpriv->ximg->data =
|
scrpriv->ximg->data =
|
||||||
xallocarray(scrpriv->ximg->stride, buffer_height);
|
calloc(scrpriv->ximg->stride, buffer_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HostX.size_set_from_configure)
|
if (!HostX.size_set_from_configure)
|
||||||
|
@ -1008,7 +1008,7 @@ hostx_screen_init(KdScreenInfo *screen,
|
||||||
*bits_per_pixel = scrpriv->server_depth;
|
*bits_per_pixel = scrpriv->server_depth;
|
||||||
|
|
||||||
EPHYR_DBG("server bpp %i", bytes_per_pixel);
|
EPHYR_DBG("server bpp %i", bytes_per_pixel);
|
||||||
scrpriv->fb_data = xallocarray (stride, buffer_height);
|
scrpriv->fb_data = calloc(stride, buffer_height);
|
||||||
return scrpriv->fb_data;
|
return scrpriv->fb_data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ KdShadowFbAlloc(KdScreenInfo * screen, Bool rotate)
|
||||||
|
|
||||||
/* use fb computation for width */
|
/* use fb computation for width */
|
||||||
paddedWidth = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof(FbBits);
|
paddedWidth = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof(FbBits);
|
||||||
buf = xallocarray(paddedWidth, height);
|
buf = calloc(paddedWidth, height);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (screen->fb.shadow)
|
if (screen->fb.shadow)
|
||||||
|
|
Loading…
Reference in New Issue