From e23e409597400c4a492f067deb8e5eeaa668f988 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 24 Feb 2025 12:15:01 +0100 Subject: [PATCH] dbe: 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 --- dbe/dbe.c | 4 ++-- dbe/midbe.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dbe/dbe.c b/dbe/dbe.c index b9c57b884..67e15ef1a 100644 --- a/dbe/dbe.c +++ b/dbe/dbe.c @@ -465,7 +465,7 @@ ProcDbeSwapBuffers(ClientPtr client) dbeSwapInfo = (xDbeSwapInfo *) &stuff[1]; /* Allocate array to record swap information. */ - swapInfo = xallocarray(nStuff, sizeof(DbeSwapInfoRec)); + swapInfo = calloc(nStuff, sizeof(DbeSwapInfoRec)); if (swapInfo == NULL) { return BadAlloc; } @@ -578,7 +578,7 @@ ProcDbeGetVisualInfo(ClientPtr client) return BadAlloc; /* Make sure any specified drawables are valid. */ if (stuff->n != 0) { - if (!(pDrawables = xallocarray(stuff->n, sizeof(DrawablePtr)))) { + if (!(pDrawables = calloc(stuff->n, sizeof(DrawablePtr)))) { return BadAlloc; } diff --git a/dbe/midbe.c b/dbe/midbe.c index ccf5aa167..3dd9152d2 100644 --- a/dbe/midbe.c +++ b/dbe/midbe.c @@ -85,7 +85,7 @@ miDbeGetVisualInfo(ScreenPtr pScreen, XdbeScreenVisualInfo * pScrVisInfo) } /* Allocate an array of XdbeVisualInfo items. */ - if (!(visInfo = xallocarray(count, sizeof(XdbeVisualInfo)))) { + if (!(visInfo = calloc(count, sizeof(XdbeVisualInfo)))) { return FALSE; /* memory alloc failure */ }