From e25852fd53ffd5831ffc717b27b62d4cf55500d5 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 24 Feb 2025 12:15:01 +0100 Subject: [PATCH] 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 --- fb/fbcopy.c | 2 +- fb/fbpict.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fb/fbcopy.c b/fb/fbcopy.c index 8f5b64b38..92cb8091c 100644 --- a/fb/fbcopy.c +++ b/fb/fbcopy.c @@ -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; diff --git a/fb/fbpict.c b/fb/fbpict.c index 9980f973f..7c98b3fb2 100644 --- a/fb/fbpict.c +++ b/fb/fbpict.c @@ -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; }