fb: 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:
Enrico Weigelt, metux IT consult 2025-02-24 12:15:01 +01:00
parent b3ef1fbbd3
commit e25852fd53
2 changed files with 2 additions and 2 deletions

View File

@ -192,7 +192,7 @@ fbCopyNto1(DrawablePtr pSrcDrawable,
height = pbox->y2 - pbox->y1;
tmpStride = ((width + FB_STIP_MASK) >> FB_STIP_SHIFT);
tmp = xallocarray(tmpStride * height, sizeof(FbStip));
tmp = calloc(tmpStride * height, sizeof(FbStip));
if (!tmp)
return;

View File

@ -123,7 +123,7 @@ fbGlyphs(CARD8 op,
pixman_glyph_cache_freeze (glyphCache);
if (n_glyphs > N_STACK_GLYPHS) {
if (!(pglyphs = xallocarray(n_glyphs, sizeof(pixman_glyph_t))))
if (!(pglyphs = calloc(n_glyphs, sizeof(pixman_glyph_t))))
goto out;
}