exa: 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
e025b8c805
commit
8e80caa6f7
|
@ -384,7 +384,7 @@ exaHWCopyNtoN(DrawablePtr pSrcDrawable,
|
|||
exaGetDrawableDeltas(pSrcDrawable, pSrcPixmap, &src_off_x, &src_off_y);
|
||||
exaGetDrawableDeltas(pDstDrawable, pDstPixmap, &dst_off_x, &dst_off_y);
|
||||
|
||||
rects = xallocarray(nbox, sizeof(xRectangle));
|
||||
rects = calloc(nbox, sizeof(xRectangle));
|
||||
|
||||
if (rects) {
|
||||
int i;
|
||||
|
@ -624,7 +624,7 @@ exaPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
|||
return;
|
||||
}
|
||||
|
||||
prect = xallocarray(npt, sizeof(xRectangle));
|
||||
prect = calloc(npt, sizeof(xRectangle));
|
||||
for (i = 0; i < npt; i++) {
|
||||
prect[i].x = ppt[i].x;
|
||||
prect[i].y = ppt[i].y;
|
||||
|
@ -665,7 +665,7 @@ exaPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
|||
return;
|
||||
}
|
||||
|
||||
prect = xallocarray(npt - 1, sizeof(xRectangle));
|
||||
prect = calloc(npt - 1, sizeof(xRectangle));
|
||||
x1 = ppt[0].x;
|
||||
y1 = ppt[0].y;
|
||||
/* If we have any non-horizontal/vertical, fall back. */
|
||||
|
@ -736,7 +736,7 @@ exaPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pSeg)
|
|||
}
|
||||
}
|
||||
|
||||
prect = xallocarray((unsigned int)nseg, sizeof(xRectangle));
|
||||
prect = calloc((unsigned int)nseg, sizeof(xRectangle));
|
||||
for (i = 0; i < nseg; i++) {
|
||||
if (pSeg[i].x1 < pSeg[i].x2) {
|
||||
prect[i].x = pSeg[i].x1;
|
||||
|
|
|
@ -209,8 +209,8 @@ exaRealizeGlyphCaches(ScreenPtr pScreen, unsigned int format)
|
|||
|
||||
cache->picture = pPicture;
|
||||
cache->picture->refcnt++;
|
||||
cache->hashEntries = xallocarray(cache->hashSize, sizeof(int));
|
||||
cache->glyphs = xallocarray(cache->size, sizeof(ExaCachedGlyphRec));
|
||||
cache->hashEntries = calloc(cache->hashSize, sizeof(int));
|
||||
cache->glyphs = calloc(cache->size, sizeof(ExaCachedGlyphRec));
|
||||
cache->glyphCount = 0;
|
||||
|
||||
if (!cache->hashEntries || !cache->glyphs)
|
||||
|
|
|
@ -203,7 +203,7 @@ exaPrepareAccessReg_mixed(PixmapPtr pPixmap, int index, RegionPtr pReg)
|
|||
|
||||
/* Do we need to allocate our system buffer? */
|
||||
if (!pExaPixmap->sys_ptr) {
|
||||
pExaPixmap->sys_ptr = xallocarray(pExaPixmap->sys_pitch,
|
||||
pExaPixmap->sys_ptr = calloc(pExaPixmap->sys_pitch,
|
||||
pPixmap->drawable.height);
|
||||
if (!pExaPixmap->sys_ptr)
|
||||
FatalError("EXA: malloc failed for size %d bytes\n",
|
||||
|
|
Loading…
Reference in New Issue