From 30c22fb1bace40e5f8decf349669035e1fd1449a 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 8a834ac3e..a22aa531b 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 76b7aaf00..fed1c9362 100644 --- a/fb/fbpict.c +++ b/fb/fbpict.c @@ -122,7 +122,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; }