Convert mi & miext to new *allocarray functions
v2: remove now useless parentheses Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
parent
70f4a0e6bd
commit
7ac2802874
25
mi/miarc.c
25
mi/miarc.c
|
@ -1187,9 +1187,9 @@ miFillSppPoly(DrawablePtr dst, GCPtr pgc, int count, /* number of points */
|
||||||
y = ymax - ymin + 1;
|
y = ymax - ymin + 1;
|
||||||
if ((count < 3) || (y <= 0))
|
if ((count < 3) || (y <= 0))
|
||||||
return;
|
return;
|
||||||
ptsOut = FirstPoint = malloc(sizeof(DDXPointRec) * y);
|
ptsOut = FirstPoint = xallocarray(y, sizeof(DDXPointRec));
|
||||||
width = FirstWidth = malloc(sizeof(int) * y);
|
width = FirstWidth = xallocarray(y, sizeof(int));
|
||||||
Marked = malloc(sizeof(int) * count);
|
Marked = xallocarray(count, sizeof(int));
|
||||||
|
|
||||||
if (!ptsOut || !width || !Marked) {
|
if (!ptsOut || !width || !Marked) {
|
||||||
free(Marked);
|
free(Marked);
|
||||||
|
@ -1679,8 +1679,7 @@ miGetArcPts(SppArcPtr parc, /* points to an arc */
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
cdt = 2 * miDcos(dt);
|
cdt = 2 * miDcos(dt);
|
||||||
if (!(poly = (SppPointPtr) realloc((void *) *ppPts,
|
if (!(poly = reallocarray(*ppPts, cpt + count, sizeof(SppPointRec))))
|
||||||
(cpt + count) * sizeof(SppPointRec))))
|
|
||||||
return 0;
|
return 0;
|
||||||
*ppPts = poly;
|
*ppPts = poly;
|
||||||
|
|
||||||
|
@ -1737,7 +1736,7 @@ addCap(miArcCapPtr * capsp, int *ncapsp, int *sizep, int end, int arcIndex)
|
||||||
|
|
||||||
if (*ncapsp == *sizep) {
|
if (*ncapsp == *sizep) {
|
||||||
newsize = *sizep + ADD_REALLOC_STEP;
|
newsize = *sizep + ADD_REALLOC_STEP;
|
||||||
cap = (miArcCapPtr) realloc(*capsp, newsize * sizeof(**capsp));
|
cap = reallocarray(*capsp, newsize, sizeof(**capsp));
|
||||||
if (!cap)
|
if (!cap)
|
||||||
return;
|
return;
|
||||||
*sizep = newsize;
|
*sizep = newsize;
|
||||||
|
@ -1760,7 +1759,7 @@ addJoin(miArcJoinPtr * joinsp,
|
||||||
|
|
||||||
if (*njoinsp == *sizep) {
|
if (*njoinsp == *sizep) {
|
||||||
newsize = *sizep + ADD_REALLOC_STEP;
|
newsize = *sizep + ADD_REALLOC_STEP;
|
||||||
join = (miArcJoinPtr) realloc(*joinsp, newsize * sizeof(**joinsp));
|
join = reallocarray(*joinsp, newsize, sizeof(**joinsp));
|
||||||
if (!join)
|
if (!join)
|
||||||
return;
|
return;
|
||||||
*sizep = newsize;
|
*sizep = newsize;
|
||||||
|
@ -1784,7 +1783,7 @@ addArc(miArcDataPtr * arcsp, int *narcsp, int *sizep, xArc * xarc)
|
||||||
|
|
||||||
if (*narcsp == *sizep) {
|
if (*narcsp == *sizep) {
|
||||||
newsize = *sizep + ADD_REALLOC_STEP;
|
newsize = *sizep + ADD_REALLOC_STEP;
|
||||||
arc = (miArcDataPtr) realloc(*arcsp, newsize * sizeof(**arcsp));
|
arc = reallocarray(*arcsp, newsize, sizeof(**arcsp));
|
||||||
if (!arc)
|
if (!arc)
|
||||||
return NULL;
|
return NULL;
|
||||||
*sizep = newsize;
|
*sizep = newsize;
|
||||||
|
@ -1890,10 +1889,10 @@ miComputeArcs(xArc * parcs, int narcs, GCPtr pGC)
|
||||||
isDoubleDash = (pGC->lineStyle == LineDoubleDash);
|
isDoubleDash = (pGC->lineStyle == LineDoubleDash);
|
||||||
dashOffset = pGC->dashOffset;
|
dashOffset = pGC->dashOffset;
|
||||||
|
|
||||||
data = malloc(narcs * sizeof(struct arcData));
|
data = xallocarray(narcs, sizeof(struct arcData));
|
||||||
if (!data)
|
if (!data)
|
||||||
return NULL;
|
return NULL;
|
||||||
arcs = malloc(sizeof(*arcs) * (isDoubleDash ? 2 : 1));
|
arcs = xallocarray(isDoubleDash ? 2 : 1, sizeof(*arcs));
|
||||||
if (!arcs) {
|
if (!arcs) {
|
||||||
free(data);
|
free(data);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -3081,8 +3080,8 @@ fillSpans(DrawablePtr pDrawable, GCPtr pGC)
|
||||||
|
|
||||||
if (nspans == 0)
|
if (nspans == 0)
|
||||||
return;
|
return;
|
||||||
xSpan = xSpans = malloc(nspans * sizeof(DDXPointRec));
|
xSpan = xSpans = xallocarray(nspans, sizeof(DDXPointRec));
|
||||||
xWidth = xWidths = malloc(nspans * sizeof(int));
|
xWidth = xWidths = xallocarray(nspans, sizeof(int));
|
||||||
if (xSpans && xWidths) {
|
if (xSpans && xWidths) {
|
||||||
i = 0;
|
i = 0;
|
||||||
f = finalSpans;
|
f = finalSpans;
|
||||||
|
@ -3136,7 +3135,7 @@ realFindSpan(int y)
|
||||||
else
|
else
|
||||||
change = SPAN_REALLOC;
|
change = SPAN_REALLOC;
|
||||||
newSize = finalSize + change;
|
newSize = finalSize + change;
|
||||||
newSpans = malloc(newSize * sizeof(struct finalSpan *));
|
newSpans = xallocarray(newSize, sizeof(struct finalSpan *));
|
||||||
if (!newSpans)
|
if (!newSpans)
|
||||||
return NULL;
|
return NULL;
|
||||||
newMiny = finalMiny;
|
newMiny = finalMiny;
|
||||||
|
|
|
@ -136,11 +136,11 @@ miCopyArea(DrawablePtr pSrcDrawable,
|
||||||
dsty += pDstDrawable->y;
|
dsty += pDstDrawable->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
pptFirst = ppt = malloc(heightSrc * sizeof(DDXPointRec));
|
pptFirst = ppt = xallocarray(heightSrc, sizeof(DDXPointRec));
|
||||||
pwidthFirst = pwidth = malloc(heightSrc * sizeof(unsigned int));
|
pwidthFirst = pwidth = xallocarray(heightSrc, sizeof(unsigned int));
|
||||||
numRects = RegionNumRects(prgnSrcClip);
|
numRects = RegionNumRects(prgnSrcClip);
|
||||||
boxes = RegionRects(prgnSrcClip);
|
boxes = RegionRects(prgnSrcClip);
|
||||||
ordering = malloc(numRects * sizeof(unsigned int));
|
ordering = xallocarray(numRects, sizeof(unsigned int));
|
||||||
if (!pptFirst || !pwidthFirst || !ordering) {
|
if (!pptFirst || !pwidthFirst || !ordering) {
|
||||||
free(ordering);
|
free(ordering);
|
||||||
free(pwidthFirst);
|
free(pwidthFirst);
|
||||||
|
@ -221,7 +221,7 @@ miCopyArea(DrawablePtr pSrcDrawable,
|
||||||
ppt++->y = y++;
|
ppt++->y = y++;
|
||||||
*pwidth++ = width;
|
*pwidth++ = width;
|
||||||
}
|
}
|
||||||
pbits = malloc(height * PixmapBytePad(width, pSrcDrawable->depth));
|
pbits = xallocarray(height, PixmapBytePad(width, pSrcDrawable->depth));
|
||||||
if (pbits) {
|
if (pbits) {
|
||||||
(*pSrcDrawable->pScreen->GetSpans) (pSrcDrawable, width, pptFirst,
|
(*pSrcDrawable->pScreen->GetSpans) (pSrcDrawable, width, pptFirst,
|
||||||
(int *) pwidthFirst, height,
|
(int *) pwidthFirst, height,
|
||||||
|
@ -398,8 +398,8 @@ miOpqStipDrawable(DrawablePtr pDraw, GCPtr pGC, RegionPtr prgnSrc,
|
||||||
ChangeGC(NullClient, pGCT, GCBackground, gcv);
|
ChangeGC(NullClient, pGCT, GCBackground, gcv);
|
||||||
ValidateGC((DrawablePtr) pPixmap, pGCT);
|
ValidateGC((DrawablePtr) pPixmap, pGCT);
|
||||||
miClearDrawable((DrawablePtr) pPixmap, pGCT);
|
miClearDrawable((DrawablePtr) pPixmap, pGCT);
|
||||||
ppt = pptFirst = malloc(h * sizeof(DDXPointRec));
|
ppt = pptFirst = xallocarray(h, sizeof(DDXPointRec));
|
||||||
pwidth = pwidthFirst = malloc(h * sizeof(int));
|
pwidth = pwidthFirst = xallocarray(h, sizeof(int));
|
||||||
if (!pptFirst || !pwidthFirst) {
|
if (!pptFirst || !pwidthFirst) {
|
||||||
free(pwidthFirst);
|
free(pwidthFirst);
|
||||||
free(pptFirst);
|
free(pptFirst);
|
||||||
|
@ -746,8 +746,8 @@ miPutImage(DrawablePtr pDraw, GCPtr pGC, int depth,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ZPixmap:
|
case ZPixmap:
|
||||||
ppt = pptFirst = malloc(h * sizeof(DDXPointRec));
|
ppt = pptFirst = xallocarray(h, sizeof(DDXPointRec));
|
||||||
pwidth = pwidthFirst = malloc(h * sizeof(int));
|
pwidth = pwidthFirst = xallocarray(h, sizeof(int));
|
||||||
if (!pptFirst || !pwidthFirst) {
|
if (!pptFirst || !pwidthFirst) {
|
||||||
free(pwidthFirst);
|
free(pwidthFirst);
|
||||||
free(pptFirst);
|
free(pptFirst);
|
||||||
|
|
|
@ -458,9 +458,9 @@ miInitVisuals(VisualPtr * visualp, DepthPtr * depthp, int *nvisualp,
|
||||||
ndepth++;
|
ndepth++;
|
||||||
nvisual += visuals->count;
|
nvisual += visuals->count;
|
||||||
}
|
}
|
||||||
depth = malloc(ndepth * sizeof(DepthRec));
|
depth = xallocarray(ndepth, sizeof(DepthRec));
|
||||||
visual = malloc(nvisual * sizeof(VisualRec));
|
visual = xallocarray(nvisual, sizeof(VisualRec));
|
||||||
preferredCVCs = malloc(ndepth * sizeof(int));
|
preferredCVCs = xallocarray(ndepth, sizeof(int));
|
||||||
if (!depth || !visual || !preferredCVCs) {
|
if (!depth || !visual || !preferredCVCs) {
|
||||||
free(depth);
|
free(depth);
|
||||||
free(visual);
|
free(visual);
|
||||||
|
@ -481,7 +481,7 @@ miInitVisuals(VisualPtr * visualp, DepthPtr * depthp, int *nvisualp,
|
||||||
prefp++;
|
prefp++;
|
||||||
vid = NULL;
|
vid = NULL;
|
||||||
if (nvtype) {
|
if (nvtype) {
|
||||||
vid = malloc(nvtype * sizeof(VisualID));
|
vid = xallocarray(nvtype, sizeof(VisualID));
|
||||||
if (!vid) {
|
if (!vid) {
|
||||||
free(depth);
|
free(depth);
|
||||||
free(visual);
|
free(visual);
|
||||||
|
|
|
@ -62,7 +62,7 @@ miCopyRegion(DrawablePtr pSrcDrawable,
|
||||||
|
|
||||||
if (nbox > 1) {
|
if (nbox > 1) {
|
||||||
/* keep ordering in each band, reverse order of bands */
|
/* keep ordering in each band, reverse order of bands */
|
||||||
pboxNew1 = (BoxPtr) malloc(sizeof(BoxRec) * nbox);
|
pboxNew1 = xallocarray(nbox, sizeof(BoxRec));
|
||||||
if (!pboxNew1)
|
if (!pboxNew1)
|
||||||
return;
|
return;
|
||||||
pboxBase = pboxNext = pbox + nbox - 1;
|
pboxBase = pboxNext = pbox + nbox - 1;
|
||||||
|
@ -93,7 +93,7 @@ miCopyRegion(DrawablePtr pSrcDrawable,
|
||||||
|
|
||||||
if (nbox > 1) {
|
if (nbox > 1) {
|
||||||
/* reverse order of rects in each band */
|
/* reverse order of rects in each band */
|
||||||
pboxNew2 = (BoxPtr) malloc(sizeof(BoxRec) * nbox);
|
pboxNew2 = xallocarray(nbox, sizeof(BoxRec));
|
||||||
if (!pboxNew2) {
|
if (!pboxNew2) {
|
||||||
free(pboxNew1);
|
free(pboxNew1);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -535,7 +535,7 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
|
||||||
gcmask |= GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin;
|
gcmask |= GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin;
|
||||||
}
|
}
|
||||||
|
|
||||||
prect = malloc(RegionNumRects(prgn) * sizeof(xRectangle));
|
prect = xallocarray(RegionNumRects(prgn), sizeof(xRectangle));
|
||||||
if (!prect)
|
if (!prect)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -100,8 +100,8 @@ miPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, /* number of rec
|
||||||
maxheight = max(maxheight, prect->height);
|
maxheight = max(maxheight, prect->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
pptFirst = malloc(maxheight * sizeof(DDXPointRec));
|
pptFirst = xallocarray(maxheight, sizeof(DDXPointRec));
|
||||||
pwFirst = malloc(maxheight * sizeof(int));
|
pwFirst = xallocarray(maxheight, sizeof(int));
|
||||||
if (!pptFirst || !pwFirst) {
|
if (!pptFirst || !pwFirst) {
|
||||||
free(pwFirst);
|
free(pwFirst);
|
||||||
free(pptFirst);
|
free(pptFirst);
|
||||||
|
|
|
@ -131,7 +131,7 @@ miPolyGlyphBlt(DrawablePtr pDrawable, GC * pGC, int x, int y, unsigned int nglyp
|
||||||
gcvals);
|
gcvals);
|
||||||
|
|
||||||
nbyLine = BitmapBytePad(width);
|
nbyLine = BitmapBytePad(width);
|
||||||
pbits = malloc(height * nbyLine);
|
pbits = xallocarray(height, nbyLine);
|
||||||
if (!pbits) {
|
if (!pbits) {
|
||||||
(*pDrawable->pScreen->DestroyPixmap) (pPixmap);
|
(*pDrawable->pScreen->DestroyPixmap) (pPixmap);
|
||||||
FreeScratchGC(pGCtmp);
|
FreeScratchGC(pGCtmp);
|
||||||
|
|
|
@ -352,8 +352,8 @@ NewExtensionModuleList(int size)
|
||||||
numExtensionModules = 0;
|
numExtensionModules = 0;
|
||||||
|
|
||||||
n = numExtensionModules + size;
|
n = numExtensionModules + size;
|
||||||
ExtensionModuleList = realloc(ExtensionModuleList,
|
ExtensionModuleList = reallocarray(ExtensionModuleList, n,
|
||||||
n * sizeof(ExtensionModule));
|
sizeof(ExtensionModule));
|
||||||
if (ExtensionModuleList == NULL) {
|
if (ExtensionModuleList == NULL) {
|
||||||
ExtensionModuleList = save;
|
ExtensionModuleList = save;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -412,8 +412,8 @@ miFillConvexPoly(DrawablePtr dst, GCPtr pgc, int count, DDXPointPtr ptsIn)
|
||||||
dy = ymax - ymin + 1;
|
dy = ymax - ymin + 1;
|
||||||
if ((count < 3) || (dy < 0))
|
if ((count < 3) || (dy < 0))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
ptsOut = FirstPoint = malloc(sizeof(DDXPointRec) * dy);
|
ptsOut = FirstPoint = xallocarray(dy, sizeof(DDXPointRec));
|
||||||
width = FirstWidth = malloc(sizeof(int) * dy);
|
width = FirstWidth = xallocarray(dy, sizeof(int));
|
||||||
if (!FirstPoint || !FirstWidth) {
|
if (!FirstPoint || !FirstWidth) {
|
||||||
free(FirstWidth);
|
free(FirstWidth);
|
||||||
free(FirstPoint);
|
free(FirstPoint);
|
||||||
|
|
|
@ -67,7 +67,7 @@ miPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, /* Origin or Previous */
|
||||||
int i;
|
int i;
|
||||||
xPoint *ppt;
|
xPoint *ppt;
|
||||||
|
|
||||||
if (!(pwidthInit = malloc(npt * sizeof(int))))
|
if (!(pwidthInit = xallocarray(npt, sizeof(int))))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* make pointlist origin relative */
|
/* make pointlist origin relative */
|
||||||
|
|
|
@ -88,7 +88,7 @@ miPolyRectangle(DrawablePtr pDraw, GCPtr pGC, int nrects, xRectangle *pRects)
|
||||||
offset2 = pGC->lineWidth;
|
offset2 = pGC->lineWidth;
|
||||||
offset1 = offset2 >> 1;
|
offset1 = offset2 >> 1;
|
||||||
offset3 = offset2 - offset1;
|
offset3 = offset2 - offset1;
|
||||||
tmp = malloc(ntmp * sizeof(xRectangle));
|
tmp = xallocarray(ntmp, sizeof(xRectangle));
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
return;
|
return;
|
||||||
t = tmp;
|
t = tmp;
|
||||||
|
|
|
@ -189,19 +189,16 @@ miSubtractSpans(SpanGroup * spanGroup, Spans * sub)
|
||||||
int *newwid;
|
int *newwid;
|
||||||
|
|
||||||
#define EXTRA 8
|
#define EXTRA 8
|
||||||
newPt =
|
newPt = reallocarray(spans->points,
|
||||||
(DDXPointPtr) realloc(spans->points,
|
spans->count + EXTRA,
|
||||||
(spans->count +
|
sizeof(DDXPointRec));
|
||||||
EXTRA) *
|
|
||||||
sizeof(DDXPointRec));
|
|
||||||
if (!newPt)
|
if (!newPt)
|
||||||
break;
|
break;
|
||||||
spansPt = newPt + (spansPt - spans->points);
|
spansPt = newPt + (spansPt - spans->points);
|
||||||
spans->points = newPt;
|
spans->points = newPt;
|
||||||
newwid =
|
newwid = reallocarray(spans->widths,
|
||||||
(int *) realloc(spans->widths,
|
spans->count + EXTRA,
|
||||||
(spans->count +
|
sizeof(int));
|
||||||
EXTRA) * sizeof(int));
|
|
||||||
if (!newwid)
|
if (!newwid)
|
||||||
break;
|
break;
|
||||||
spansWid = newwid + (spansWid - spans->widths);
|
spansWid = newwid + (spansWid - spans->widths);
|
||||||
|
@ -240,8 +237,8 @@ miAppendSpans(SpanGroup * spanGroup, SpanGroup * otherGroup, Spans * spans)
|
||||||
if (spansCount > 0) {
|
if (spansCount > 0) {
|
||||||
if (spanGroup->size == spanGroup->count) {
|
if (spanGroup->size == spanGroup->count) {
|
||||||
spanGroup->size = (spanGroup->size + 8) * 2;
|
spanGroup->size = (spanGroup->size + 8) * 2;
|
||||||
spanGroup->group = (Spans *)
|
spanGroup->group =
|
||||||
realloc(spanGroup->group, sizeof(Spans) * spanGroup->size);
|
reallocarray(spanGroup->group, sizeof(Spans), spanGroup->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
spanGroup->group[spanGroup->count] = *spans;
|
spanGroup->group[spanGroup->count] = *spans;
|
||||||
|
@ -456,8 +453,8 @@ miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup * spanGroup)
|
||||||
ylength = spanGroup->ymax - ymin + 1;
|
ylength = spanGroup->ymax - ymin + 1;
|
||||||
|
|
||||||
/* Allocate Spans for y buckets */
|
/* Allocate Spans for y buckets */
|
||||||
yspans = malloc(ylength * sizeof(Spans));
|
yspans = xallocarray(ylength, sizeof(Spans));
|
||||||
ysizes = malloc(ylength * sizeof(int));
|
ysizes = xallocarray(ylength, sizeof(int));
|
||||||
|
|
||||||
if (!yspans || !ysizes) {
|
if (!yspans || !ysizes) {
|
||||||
free(yspans);
|
free(yspans);
|
||||||
|
@ -491,12 +488,11 @@ miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup * spanGroup)
|
||||||
int *newwidths;
|
int *newwidths;
|
||||||
|
|
||||||
ysizes[index] = (ysizes[index] + 8) * 2;
|
ysizes[index] = (ysizes[index] + 8) * 2;
|
||||||
newpoints = (DDXPointPtr) realloc(newspans->points,
|
newpoints = reallocarray(newspans->points,
|
||||||
ysizes[index] *
|
ysizes[index],
|
||||||
sizeof(DDXPointRec));
|
sizeof(DDXPointRec));
|
||||||
newwidths =
|
newwidths = reallocarray(newspans->widths,
|
||||||
(int *) realloc(newspans->widths,
|
ysizes[index], sizeof(int));
|
||||||
ysizes[index] * sizeof(int));
|
|
||||||
if (!newpoints || !newwidths) {
|
if (!newpoints || !newwidths) {
|
||||||
for (i = 0; i < ylength; i++) {
|
for (i = 0; i < ylength; i++) {
|
||||||
free(yspans[i].points);
|
free(yspans[i].points);
|
||||||
|
@ -525,8 +521,8 @@ miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup * spanGroup)
|
||||||
} /* for i thorough Spans */
|
} /* for i thorough Spans */
|
||||||
|
|
||||||
/* Now sort by x and uniquify each bucket into the final array */
|
/* Now sort by x and uniquify each bucket into the final array */
|
||||||
points = malloc(count * sizeof(DDXPointRec));
|
points = xallocarray(count, sizeof(DDXPointRec));
|
||||||
widths = malloc(count * sizeof(int));
|
widths = xallocarray(count, sizeof(int));
|
||||||
if (!points || !widths) {
|
if (!points || !widths) {
|
||||||
for (i = 0; i < ylength; i++) {
|
for (i = 0; i < ylength; i++) {
|
||||||
free(yspans[i].points);
|
free(yspans[i].points);
|
||||||
|
@ -573,10 +569,10 @@ miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup * spanGroup)
|
||||||
static Bool
|
static Bool
|
||||||
InitSpans(Spans * spans, size_t nspans)
|
InitSpans(Spans * spans, size_t nspans)
|
||||||
{
|
{
|
||||||
spans->points = malloc(nspans * sizeof(*spans->points));
|
spans->points = xallocarray(nspans, sizeof(*spans->points));
|
||||||
if (!spans->points)
|
if (!spans->points)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
spans->widths = malloc(nspans * sizeof(*spans->widths));
|
spans->widths = xallocarray(nspans, sizeof(*spans->widths));
|
||||||
if (!spans->widths) {
|
if (!spans->widths) {
|
||||||
free(spans->points);
|
free(spans->points);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -777,9 +777,9 @@ miSpriteTrace(SpritePtr pSprite, int x, int y)
|
||||||
) {
|
) {
|
||||||
if (pSprite->spriteTraceGood >= pSprite->spriteTraceSize) {
|
if (pSprite->spriteTraceGood >= pSprite->spriteTraceSize) {
|
||||||
pSprite->spriteTraceSize += 10;
|
pSprite->spriteTraceSize += 10;
|
||||||
pSprite->spriteTrace = realloc(pSprite->spriteTrace,
|
pSprite->spriteTrace = reallocarray(pSprite->spriteTrace,
|
||||||
pSprite->spriteTraceSize *
|
pSprite->spriteTraceSize,
|
||||||
sizeof(WindowPtr));
|
sizeof(WindowPtr));
|
||||||
}
|
}
|
||||||
pSprite->spriteTrace[pSprite->spriteTraceGood++] = pWin;
|
pSprite->spriteTrace[pSprite->spriteTraceGood++] = pWin;
|
||||||
pWin = pWin->firstChild;
|
pWin = pWin->firstChild;
|
||||||
|
|
|
@ -671,7 +671,7 @@ miZeroPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
|
||||||
numPts = maxPts << 2;
|
numPts = maxPts << 2;
|
||||||
dospans = (pGC->fillStyle != FillSolid);
|
dospans = (pGC->fillStyle != FillSolid);
|
||||||
if (dospans) {
|
if (dospans) {
|
||||||
widths = malloc(sizeof(int) * numPts);
|
widths = xallocarray(numPts, sizeof(int));
|
||||||
if (!widths)
|
if (!widths)
|
||||||
return;
|
return;
|
||||||
maxw = 0;
|
maxw = 0;
|
||||||
|
@ -687,7 +687,7 @@ miZeroPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
|
||||||
(unsigned char *) pGC->dash, (int) pGC->numInDashList,
|
(unsigned char *) pGC->dash, (int) pGC->numInDashList,
|
||||||
&dinfo.dashOffsetInit);
|
&dinfo.dashOffsetInit);
|
||||||
}
|
}
|
||||||
points = malloc(sizeof(DDXPointRec) * numPts);
|
points = xallocarray(numPts, sizeof(DDXPointRec));
|
||||||
if (!points) {
|
if (!points) {
|
||||||
if (dospans) {
|
if (dospans) {
|
||||||
free(widths);
|
free(widths);
|
||||||
|
|
|
@ -150,8 +150,8 @@ miZeroLine(DrawablePtr pDraw, GCPtr pGC, int mode, /* Origin or Previous */
|
||||||
width = xright - xleft + 1;
|
width = xright - xleft + 1;
|
||||||
height = ybottom - ytop + 1;
|
height = ybottom - ytop + 1;
|
||||||
list_len = (height >= width) ? height : width;
|
list_len = (height >= width) ? height : width;
|
||||||
pspanInit = malloc(list_len * sizeof(DDXPointRec));
|
pspanInit = xallocarray(list_len, sizeof(DDXPointRec));
|
||||||
pwidthInit = malloc(list_len * sizeof(int));
|
pwidthInit = xallocarray(list_len, sizeof(int));
|
||||||
if (!pspanInit || !pwidthInit) {
|
if (!pspanInit || !pwidthInit) {
|
||||||
free(pspanInit);
|
free(pspanInit);
|
||||||
free(pwidthInit);
|
free(pwidthInit);
|
||||||
|
|
|
@ -1293,7 +1293,7 @@ damageText(DrawablePtr pDrawable,
|
||||||
if (!checkGCDamage(pDrawable, pGC))
|
if (!checkGCDamage(pDrawable, pGC))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
charinfo = malloc(count * sizeof(CharInfoPtr));
|
charinfo = xallocarray(count, sizeof(CharInfoPtr));
|
||||||
if (!charinfo)
|
if (!charinfo)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -949,7 +949,7 @@ StartFrameResize(WindowPtr pWin, Bool gravity,
|
||||||
copy_rect_width = copy_rect.x2 - copy_rect.x1;
|
copy_rect_width = copy_rect.x2 - copy_rect.x1;
|
||||||
copy_rect_height = copy_rect.y2 - copy_rect.y1;
|
copy_rect_height = copy_rect.y2 - copy_rect.y1;
|
||||||
copy_rowbytes = ((copy_rect_width * Bpp) + 31) & ~31;
|
copy_rowbytes = ((copy_rect_width * Bpp) + 31) & ~31;
|
||||||
gResizeDeathBits = malloc(copy_rowbytes * copy_rect_height);
|
gResizeDeathBits = xallocarray(copy_rowbytes, copy_rect_height);
|
||||||
|
|
||||||
if (copy_rect_width * copy_rect_height >
|
if (copy_rect_width * copy_rect_height >
|
||||||
rootless_CopyBytes_threshold &&
|
rootless_CopyBytes_threshold &&
|
||||||
|
@ -998,7 +998,7 @@ StartFrameResize(WindowPtr pWin, Bool gravity,
|
||||||
|
|
||||||
RootlessStartDrawing(pWin);
|
RootlessStartDrawing(pWin);
|
||||||
|
|
||||||
gResizeDeathBits = malloc(winRec->bytesPerRow * winRec->height);
|
gResizeDeathBits = xallocarray(winRec->bytesPerRow, winRec->height);
|
||||||
|
|
||||||
memcpy(gResizeDeathBits, winRec->pixelData,
|
memcpy(gResizeDeathBits, winRec->pixelData,
|
||||||
winRec->bytesPerRow * winRec->height);
|
winRec->bytesPerRow * winRec->height);
|
||||||
|
|
|
@ -44,6 +44,6 @@ shadowAlloc(int width, int height, int bpp)
|
||||||
|
|
||||||
/* Cant use PixmapBytePad -- the structure is probably not initialized yet */
|
/* Cant use PixmapBytePad -- the structure is probably not initialized yet */
|
||||||
stride = BitmapBytePad(width * bpp);
|
stride = BitmapBytePad(width * bpp);
|
||||||
fb = malloc(stride * height);
|
fb = xallocarray(stride, height);
|
||||||
return fb;
|
return fb;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue