Convert exa & fb to new *allocarray functions

v2: fixup whitespace

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
This commit is contained in:
Alan Coopersmith 2015-03-21 14:40:39 -07:00
parent 4fe6b03b97
commit 70f4a0e6bd
5 changed files with 10 additions and 10 deletions

View File

@ -386,7 +386,7 @@ exaHWCopyNtoN(DrawablePtr pSrcDrawable,
exaGetDrawableDeltas(pSrcDrawable, pSrcPixmap, &src_off_x, &src_off_y); exaGetDrawableDeltas(pSrcDrawable, pSrcPixmap, &src_off_x, &src_off_y);
exaGetDrawableDeltas(pDstDrawable, pDstPixmap, &dst_off_x, &dst_off_y); exaGetDrawableDeltas(pDstDrawable, pDstPixmap, &dst_off_x, &dst_off_y);
rects = malloc(nbox * sizeof(xRectangle)); rects = xallocarray(nbox, sizeof(xRectangle));
if (rects) { if (rects) {
int i; int i;
@ -626,7 +626,7 @@ exaPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
return; return;
} }
prect = malloc(sizeof(xRectangle) * npt); prect = xallocarray(npt, sizeof(xRectangle));
for (i = 0; i < npt; i++) { for (i = 0; i < npt; i++) {
prect[i].x = ppt[i].x; prect[i].x = ppt[i].x;
prect[i].y = ppt[i].y; prect[i].y = ppt[i].y;
@ -667,7 +667,7 @@ exaPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
return; return;
} }
prect = malloc(sizeof(xRectangle) * (npt - 1)); prect = xallocarray(npt - 1, sizeof(xRectangle));
x1 = ppt[0].x; x1 = ppt[0].x;
y1 = ppt[0].y; y1 = ppt[0].y;
/* If we have any non-horizontal/vertical, fall back. */ /* If we have any non-horizontal/vertical, fall back. */
@ -738,7 +738,7 @@ exaPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pSeg)
} }
} }
prect = malloc(sizeof(xRectangle) * nseg); prect = xallocarray(nseg, sizeof(xRectangle));
for (i = 0; i < nseg; i++) { for (i = 0; i < nseg; i++) {
if (pSeg[i].x1 < pSeg[i].x2) { if (pSeg[i].x1 < pSeg[i].x2) {
prect[i].x = pSeg[i].x1; prect[i].x = pSeg[i].x1;

View File

@ -211,8 +211,8 @@ exaRealizeGlyphCaches(ScreenPtr pScreen, unsigned int format)
cache->picture = pPicture; cache->picture = pPicture;
cache->picture->refcnt++; cache->picture->refcnt++;
cache->hashEntries = malloc(sizeof(int) * cache->hashSize); cache->hashEntries = xallocarray(cache->hashSize, sizeof(int));
cache->glyphs = malloc(sizeof(ExaCachedGlyphRec) * cache->size); cache->glyphs = xallocarray(cache->size, sizeof(ExaCachedGlyphRec));
cache->glyphCount = 0; cache->glyphCount = 0;
if (!cache->hashEntries || !cache->glyphs) if (!cache->hashEntries || !cache->glyphs)

View File

@ -205,8 +205,8 @@ exaPrepareAccessReg_mixed(PixmapPtr pPixmap, int index, RegionPtr pReg)
/* Do we need to allocate our system buffer? */ /* Do we need to allocate our system buffer? */
if (!pExaPixmap->sys_ptr) { if (!pExaPixmap->sys_ptr) {
pExaPixmap->sys_ptr = malloc(pExaPixmap->sys_pitch * pExaPixmap->sys_ptr = xallocarray(pExaPixmap->sys_pitch,
pPixmap->drawable.height); pPixmap->drawable.height);
if (!pExaPixmap->sys_ptr) if (!pExaPixmap->sys_ptr)
FatalError("EXA: malloc failed for size %d bytes\n", FatalError("EXA: malloc failed for size %d bytes\n",
pExaPixmap->sys_pitch * pPixmap->drawable.height); pExaPixmap->sys_pitch * pPixmap->drawable.height);

View File

@ -194,7 +194,7 @@ fbCopyNto1(DrawablePtr pSrcDrawable,
height = pbox->y2 - pbox->y1; height = pbox->y2 - pbox->y1;
tmpStride = ((width + FB_STIP_MASK) >> FB_STIP_SHIFT); tmpStride = ((width + FB_STIP_MASK) >> FB_STIP_SHIFT);
tmp = malloc(tmpStride * height * sizeof(FbStip)); tmp = xallocarray(tmpStride * height, sizeof(FbStip));
if (!tmp) if (!tmp)
return; return;

View File

@ -124,7 +124,7 @@ fbGlyphs(CARD8 op,
pixman_glyph_cache_freeze (glyphCache); pixman_glyph_cache_freeze (glyphCache);
if (n_glyphs > N_STACK_GLYPHS) { if (n_glyphs > N_STACK_GLYPHS) {
if (!(pglyphs = malloc (n_glyphs * sizeof (pixman_glyph_t)))) if (!(pglyphs = xallocarray(n_glyphs, sizeof(pixman_glyph_t))))
goto out; goto out;
} }