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:
parent
953f0a68dc
commit
037a595ad7
|
@ -376,7 +376,7 @@ SetPicturePictFilter(PicturePtr pPicture, PictFilterPtr pFilter,
|
||||||
return BadMatch;
|
return BadMatch;
|
||||||
|
|
||||||
if (nparams != pPicture->filter_nparams) {
|
if (nparams != pPicture->filter_nparams) {
|
||||||
xFixed *new_params = xallocarray(nparams, sizeof(xFixed));
|
xFixed *new_params = calloc(nparams, sizeof(xFixed));
|
||||||
|
|
||||||
if (!new_params && nparams)
|
if (!new_params && nparams)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
|
|
|
@ -249,7 +249,7 @@ miInitIndexed(ScreenPtr pScreen, PictFormatPtr pFormat)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
pFormat->index.nvalues = num;
|
pFormat->index.nvalues = num;
|
||||||
pFormat->index.pValues = xallocarray(num, sizeof(xIndexValue));
|
pFormat->index.pValues = calloc(num, sizeof(xIndexValue));
|
||||||
if (!pFormat->index.pValues) {
|
if (!pFormat->index.pValues) {
|
||||||
free(pIndexed);
|
free(pIndexed);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -508,7 +508,7 @@ miTriStrip(CARD8 op,
|
||||||
int ntri;
|
int ntri;
|
||||||
|
|
||||||
ntri = npoints - 2;
|
ntri = npoints - 2;
|
||||||
tris = xallocarray(ntri, sizeof(xTriangle));
|
tris = calloc(ntri, sizeof(xTriangle));
|
||||||
if (!tris)
|
if (!tris)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -533,7 +533,7 @@ miTriFan(CARD8 op,
|
||||||
int ntri;
|
int ntri;
|
||||||
|
|
||||||
ntri = npoints - 2;
|
ntri = npoints - 2;
|
||||||
tris = xallocarray(ntri, sizeof(xTriangle));
|
tris = calloc(ntri, sizeof(xTriangle));
|
||||||
if (!tris)
|
if (!tris)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -811,7 +811,7 @@ initGradient(SourcePictPtr pGradient, int stopCount,
|
||||||
dpos = stopPoints[i];
|
dpos = stopPoints[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
pGradient->gradient.stops = xallocarray(stopCount, sizeof(PictGradientStop));
|
pGradient->gradient.stops = calloc(stopCount, sizeof(PictGradientStop));
|
||||||
if (!pGradient->gradient.stops) {
|
if (!pGradient->gradient.stops) {
|
||||||
*error = BadAlloc;
|
*error = BadAlloc;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1313,14 +1313,14 @@ ProcRenderCompositeGlyphs(ClientPtr client)
|
||||||
if (nglyph <= NLOCALGLYPH)
|
if (nglyph <= NLOCALGLYPH)
|
||||||
glyphsBase = glyphsLocal;
|
glyphsBase = glyphsLocal;
|
||||||
else {
|
else {
|
||||||
glyphsBase = xallocarray(nglyph, sizeof(GlyphPtr));
|
glyphsBase = calloc(nglyph, sizeof(GlyphPtr));
|
||||||
if (!glyphsBase)
|
if (!glyphsBase)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
}
|
}
|
||||||
if (nlist <= NLOCALDELTA)
|
if (nlist <= NLOCALDELTA)
|
||||||
listsBase = listsLocal;
|
listsBase = listsLocal;
|
||||||
else {
|
else {
|
||||||
listsBase = xallocarray(nlist, sizeof(GlyphListRec));
|
listsBase = calloc(nlist, sizeof(GlyphListRec));
|
||||||
if (!listsBase) {
|
if (!listsBase) {
|
||||||
rc = BadAlloc;
|
rc = BadAlloc;
|
||||||
goto bail;
|
goto bail;
|
||||||
|
@ -1799,7 +1799,7 @@ ProcRenderCreateAnimCursor(ClientPtr client)
|
||||||
ncursor =
|
ncursor =
|
||||||
(client->req_len -
|
(client->req_len -
|
||||||
(bytes_to_int32(sizeof(xRenderCreateAnimCursorReq)))) >> 1;
|
(bytes_to_int32(sizeof(xRenderCreateAnimCursorReq)))) >> 1;
|
||||||
cursors = xallocarray(ncursor, sizeof(CursorPtr) + sizeof(CARD32));
|
cursors = calloc(ncursor, sizeof(CursorPtr) + sizeof(CARD32));
|
||||||
if (!cursors)
|
if (!cursors)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
deltas = (CARD32 *) (cursors + ncursor);
|
deltas = (CARD32 *) (cursors + ncursor);
|
||||||
|
|
Loading…
Reference in New Issue