render: 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 <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2025-02-24 12:15:01 +01:00
committed by Enrico Weigelt, metux IT consult .
parent 2263e514c4
commit d481c8311a
5 changed files with 8 additions and 8 deletions

View File

@@ -1316,14 +1316,14 @@ ProcRenderCompositeGlyphs(ClientPtr client)
if (nglyph <= NLOCALGLYPH)
glyphsBase = glyphsLocal;
else {
glyphsBase = xallocarray(nglyph, sizeof(GlyphPtr));
glyphsBase = calloc(nglyph, sizeof(GlyphPtr));
if (!glyphsBase)
return BadAlloc;
}
if (nlist <= NLOCALDELTA)
listsBase = listsLocal;
else {
listsBase = xallocarray(nlist, sizeof(GlyphListRec));
listsBase = calloc(nlist, sizeof(GlyphListRec));
if (!listsBase) {
rc = BadAlloc;
goto bail;
@@ -1799,7 +1799,7 @@ ProcRenderCreateAnimCursor(ClientPtr client)
ncursor =
(client->req_len -
(bytes_to_int32(sizeof(xRenderCreateAnimCursorReq)))) >> 1;
cursors = xallocarray(ncursor, sizeof(CursorPtr) + sizeof(CARD32));
cursors = calloc(ncursor, sizeof(CursorPtr) + sizeof(CARD32));
if (!cursors)
return BadAlloc;
deltas = (CARD32 *) (cursors + ncursor);