xext: 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
parent 3d60cfbb68
commit dda64fcadf
9 changed files with 22 additions and 22 deletions

View File

@@ -1410,7 +1410,7 @@ PanoramiXPolyPoint(ClientPtr client)
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq));
if (npoint > 0) {
origPts = xallocarray(npoint, sizeof(xPoint));
origPts = calloc(npoint, sizeof(xPoint));
memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint));
FOR_NSCREENS_FORWARD(j) {
@@ -1475,7 +1475,7 @@ PanoramiXPolyLine(ClientPtr client)
isRoot = IS_ROOT_DRAWABLE(draw);
npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq));
if (npoint > 0) {
origPts = xallocarray(npoint, sizeof(xPoint));
origPts = calloc(npoint, sizeof(xPoint));
memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint));
FOR_NSCREENS_FORWARD(j) {
@@ -1544,7 +1544,7 @@ PanoramiXPolySegment(ClientPtr client)
return BadLength;
nsegs >>= 3;
if (nsegs > 0) {
origSegs = xallocarray(nsegs, sizeof(xSegment));
origSegs = calloc(nsegs, sizeof(xSegment));
memcpy((char *) origSegs, (char *) &stuff[1], nsegs * sizeof(xSegment));
FOR_NSCREENS_FORWARD(j) {
@@ -1612,7 +1612,7 @@ PanoramiXPolyRectangle(ClientPtr client)
return BadLength;
nrects >>= 3;
if (nrects > 0) {
origRecs = xallocarray(nrects, sizeof(xRectangle));
origRecs = calloc(nrects, sizeof(xRectangle));
memcpy((char *) origRecs, (char *) &stuff[1],
nrects * sizeof(xRectangle));
FOR_NSCREENS_FORWARD(j) {
@@ -1679,7 +1679,7 @@ PanoramiXPolyArc(ClientPtr client)
return BadLength;
narcs /= sizeof(xArc);
if (narcs > 0) {
origArcs = xallocarray(narcs, sizeof(xArc));
origArcs = calloc(narcs, sizeof(xArc));
memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc));
FOR_NSCREENS_FORWARD(j) {
@@ -1741,7 +1741,7 @@ PanoramiXFillPoly(ClientPtr client)
count = bytes_to_int32((client->req_len << 2) - sizeof(xFillPolyReq));
if (count > 0) {
locPts = xallocarray(count, sizeof(DDXPointRec));
locPts = calloc(count, sizeof(DDXPointRec));
memcpy((char *) locPts, (char *) &stuff[1],
count * sizeof(DDXPointRec));
FOR_NSCREENS_FORWARD(j) {
@@ -1810,7 +1810,7 @@ PanoramiXPolyFillRectangle(ClientPtr client)
return BadLength;
things >>= 3;
if (things > 0) {
origRects = xallocarray(things, sizeof(xRectangle));
origRects = calloc(things, sizeof(xRectangle));
memcpy((char *) origRects, (char *) &stuff[1],
things * sizeof(xRectangle));
FOR_NSCREENS_FORWARD(j) {
@@ -1877,7 +1877,7 @@ PanoramiXPolyFillArc(ClientPtr client)
return BadLength;
narcs /= sizeof(xArc);
if (narcs > 0) {
origArcs = xallocarray(narcs, sizeof(xArc));
origArcs = calloc(narcs, sizeof(xArc));
memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc));
FOR_NSCREENS_FORWARD(j) {
@@ -2063,7 +2063,7 @@ PanoramiXGetImage(ClientPtr client)
if (linesPerBuf > h)
linesPerBuf = h;
}
if (!(pBuf = xallocarray(linesPerBuf, widthBytesLine)))
if (!(pBuf = calloc(linesPerBuf, widthBytesLine)))
return BadAlloc;
if (client->swapped) {