From f55e01f5d8a7a66fefd5ce19669bca4fbeb13010 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 24 Feb 2025 12:15:01 +0100 Subject: [PATCH] xfixes: 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 --- xfixes/region.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xfixes/region.c b/xfixes/region.c index 79f22e521..3f3fb4cdc 100644 --- a/xfixes/region.c +++ b/xfixes/region.c @@ -748,7 +748,7 @@ ProcXFixesExpandRegion(ClientPtr client) nBoxes = RegionNumRects(pSource); pSrc = RegionRects(pSource); if (nBoxes) { - pTmp = xallocarray(nBoxes, sizeof(BoxRec)); + pTmp = calloc(nBoxes, sizeof(BoxRec)); if (!pTmp) return BadAlloc; for (i = 0; i < nBoxes; i++) {