From f0257bfe93a717ac9f9dd7297cf7a3ba15cf2120 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 24 Feb 2025 12:15:01 +0100 Subject: [PATCH] xvfb: 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 --- hw/vfb/InitOutput.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c index 3670446ac..a2d48b630 100644 --- a/hw/vfb/InitOutput.c +++ b/hw/vfb/InitOutput.c @@ -481,9 +481,9 @@ vfbInstallColormap(ColormapPtr pmap) swapcopy32(pXWDHeader->bits_per_rgb, pVisual->bitsPerRGBValue); swapcopy32(pXWDHeader->colormap_entries, pVisual->ColormapEntries); - ppix = xallocarray(entries, sizeof(Pixel)); - prgb = xallocarray(entries, sizeof(xrgb)); - defs = xallocarray(entries, sizeof(xColorItem)); + ppix = calloc(entries, sizeof(Pixel)); + prgb = calloc(entries, sizeof(xrgb)); + defs = calloc(entries, sizeof(xColorItem)); for (i = 0; i < entries; i++) ppix[i] = i;