Commit caf54506 authored by Daniel Stone's avatar Daniel Stone
Browse files

KDrive: Remove usage of alloca

Replace with heap allocations.
parent d57060f1
......@@ -331,7 +331,7 @@ epsonCreateColormap (ColormapPtr pmap)
case FB_VISUAL_STATIC_PSEUDOCOLOR:
pVisual = pmap->pVisual;
nent = pVisual->ColormapEntries;
pdefs = ALLOCATE_LOCAL (nent * sizeof (xColorItem));
pdefs = xalloc (nent * sizeof (xColorItem));
if (!pdefs)
return FALSE;
for (i = 0; i < nent; i++)
......@@ -343,7 +343,7 @@ epsonCreateColormap (ColormapPtr pmap)
pmap->red[i].co.local.green = pdefs[i].green;
pmap->red[i].co.local.blue = pdefs[i].blue;
}
DEALLOCATE_LOCAL (pdefs);
xfree (pdefs);
return TRUE;
default:
......
......@@ -598,7 +598,7 @@ fbdevCreateColormap (ColormapPtr pmap)
case FB_VISUAL_STATIC_PSEUDOCOLOR:
pVisual = pmap->pVisual;
nent = pVisual->ColormapEntries;
pdefs = ALLOCATE_LOCAL (nent * sizeof (xColorItem));
pdefs = xalloc (nent * sizeof (xColorItem));
if (!pdefs)
return FALSE;
for (i = 0; i < nent; i++)
......@@ -610,7 +610,7 @@ fbdevCreateColormap (ColormapPtr pmap)
pmap->red[i].co.local.green = pdefs[i].green;
pmap->red[i].co.local.blue = pdefs[i].blue;
}
DEALLOCATE_LOCAL (pdefs);
xfree (pdefs);
return TRUE;
default:
return fbInitializeColormap (pmap);
......
......@@ -553,12 +553,12 @@ igsFillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
return;
}
nTmp = n * miFindMaxBand(fbGetCompositeClip(pGC));
pwidthFree = (int *)ALLOCATE_LOCAL(nTmp * sizeof(int));
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(nTmp * sizeof(DDXPointRec));
pwidthFree = (int *)xalloc(nTmp * sizeof(int));
pptFree = (DDXPointRec *)xalloc(nTmp * sizeof(DDXPointRec));
if(!pptFree || !pwidthFree)
{
if (pptFree) DEALLOCATE_LOCAL(pptFree);
if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
if (pptFree) xfree(pptFree);
if (pwidthFree) xfree(pwidthFree);
return;
}
n = miClipSpans(fbGetCompositeClip(pGC),
......@@ -607,8 +607,8 @@ igsFillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
_igsPatRect(cop,x,y,width,1,cmd);
}
}
DEALLOCATE_LOCAL(pptFree);
DEALLOCATE_LOCAL(pwidthFree);
xfree(pptFree);
xfree(pwidthFree);
KdMarkSync (pDrawable->pScreen);
}
......
......@@ -343,7 +343,7 @@ nvidiaPaintRegion (ScreenPtr pScreen, RegionPtr pRgn, Pixel fg)
BoxPtr pBox = REGION_RECTS (pRgn);
int nBox = REGION_NUM_RECTS (pRgn);
rects = ALLOCATE_LOCAL (nBox * sizeof (xRectangle));
rects = xalloc (nBox * sizeof (xRectangle));
if (!rects)
goto bail0;
r = rects;
......@@ -372,7 +372,7 @@ nvidiaPaintRegion (ScreenPtr pScreen, RegionPtr pRgn, Pixel fg)
FreeScratchGC (pGC);
bail1:
DEALLOCATE_LOCAL (rects);
xfree (rects);
bail0:
;
}
......
......@@ -519,7 +519,7 @@ s3PolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
if (numRects > NUM_STACK_RECTS)
{
pboxClippedBase = (BoxPtr)ALLOCATE_LOCAL(numRects * sizeof(BoxRec));
pboxClippedBase = (BoxPtr)xalloc(numRects * sizeof(BoxRec));
if (!pboxClippedBase)
return;
}
......@@ -637,7 +637,7 @@ s3PolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
pboxClippedBase);
}
if (pboxClippedBase != stackRects)
DEALLOCATE_LOCAL(pboxClippedBase);
xfree(pboxClippedBase);
}
void
......@@ -771,12 +771,12 @@ s3FillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
else
{
nTmp = n * miFindMaxBand(pClip);
pwidthFree = (int *)ALLOCATE_LOCAL(nTmp * sizeof(int));
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(nTmp * sizeof(DDXPointRec));
pwidthFree = (int *)xalloc(nTmp * sizeof(int));
pptFree = (DDXPointRec *)xalloc(nTmp * sizeof(DDXPointRec));
if(!pptFree || !pwidthFree)
{
if (pptFree) DEALLOCATE_LOCAL(pptFree);
if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
if (pptFree) xfree(pptFree);
if (pwidthFree) xfree(pwidthFree);
return;
}
n = miClipSpans(fbGetCompositeClip(pGC),
......@@ -820,8 +820,8 @@ s3FillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
{
_s3FillSpanLargeStipple (pDrawable, pGC, n, ppt, pwidth);
}
DEALLOCATE_LOCAL(pptFree);
DEALLOCATE_LOCAL(pwidthFree);
xfree(pptFree);
xfree(pwidthFree);
}
MarkSyncS3 (pDrawable->pScreen);
}
......@@ -2449,12 +2449,12 @@ s3_24FillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
else
{
nTmp = n * miFindMaxBand(pClip);
pwidthFree = (int *)ALLOCATE_LOCAL(nTmp * sizeof(int));
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(nTmp * sizeof(DDXPointRec));
pwidthFree = (int *)xalloc(nTmp * sizeof(int));
pptFree = (DDXPointRec *)xalloc(nTmp * sizeof(DDXPointRec));
if(!pptFree || !pwidthFree)
{
if (pptFree) DEALLOCATE_LOCAL(pptFree);
if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
if (pptFree) xfree(pptFree);
if (pwidthFree) xfree(pwidthFree);
return;
}
n = miClipSpans(fbGetCompositeClip(pGC),
......@@ -2474,8 +2474,8 @@ s3_24FillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
_s3SolidRect(s3,x*3,y,width*3,1);
}
}
DEALLOCATE_LOCAL(pptFree);
DEALLOCATE_LOCAL(pwidthFree);
xfree(pptFree);
xfree(pwidthFree);
}
MarkSyncS3 (pDrawable->pScreen);
}
......@@ -2610,7 +2610,7 @@ s3_24PolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
if (numRects > NUM_STACK_RECTS)
{
pboxClippedBase = (BoxPtr)ALLOCATE_LOCAL(numRects * sizeof(BoxRec));
pboxClippedBase = (BoxPtr)xalloc(numRects * sizeof(BoxRec));
if (!pboxClippedBase)
return;
}
......@@ -2718,7 +2718,7 @@ s3_24PolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
pGC->fgPixel, pGC->alu, pGC->planemask);
}
if (pboxClippedBase != stackRects)
DEALLOCATE_LOCAL(pboxClippedBase);
xfree(pboxClippedBase);
}
void
......
......@@ -1234,12 +1234,12 @@ sisFillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
return;
}
nTmp = n * miFindMaxBand(fbGetCompositeClip(pGC));
pwidthFree = (int *)ALLOCATE_LOCAL(nTmp * sizeof(int));
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(nTmp * sizeof(DDXPointRec));
pwidthFree = (int *)xalloc(nTmp * sizeof(int));
pptFree = (DDXPointRec *)xalloc(nTmp * sizeof(DDXPointRec));
if(!pptFree || !pwidthFree)
{
if (pptFree) DEALLOCATE_LOCAL(pptFree);
if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
if (pptFree) xfree(pptFree);
if (pwidthFree) xfree(pwidthFree);
return;
}
n = miClipSpans(fbGetCompositeClip(pGC),
......@@ -1273,8 +1273,8 @@ sisFillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
}
}
KdMarkSync (pDrawable->pScreen);
DEALLOCATE_LOCAL(pptFree);
DEALLOCATE_LOCAL(pwidthFree);
xfree(pptFree);
xfree(pwidthFree);
}
#define NUM_STACK_RECTS 1024
......@@ -1323,7 +1323,7 @@ sisPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
if (numRects > NUM_STACK_RECTS)
{
pboxClippedBase = (BoxPtr)ALLOCATE_LOCAL(numRects * sizeof(BoxRec));
pboxClippedBase = (BoxPtr)xalloc(numRects * sizeof(BoxRec));
if (!pboxClippedBase)
return;
}
......@@ -1448,7 +1448,7 @@ sisPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
}
}
if (pboxClippedBase != stackRects)
DEALLOCATE_LOCAL(pboxClippedBase);
xfree(pboxClippedBase);
}
static const GCOps sisOps = {
......
......@@ -342,7 +342,7 @@ mach64PaintRegion (ScreenPtr pScreen, RegionPtr pRgn, Pixel fg)
BoxPtr pBox = REGION_RECTS (pRgn);
int nBox = REGION_NUM_RECTS (pRgn);
rects = ALLOCATE_LOCAL (nBox * sizeof (xRectangle));
rects = xalloc (nBox * sizeof (xRectangle));
if (!rects)
goto bail0;
r = rects;
......@@ -371,7 +371,7 @@ mach64PaintRegion (ScreenPtr pScreen, RegionPtr pRgn, Pixel fg)
FreeScratchGC (pGC);
bail1:
DEALLOCATE_LOCAL (rects);
xfree (rects);
bail0:
;
}
......
......@@ -1927,7 +1927,7 @@ KXVPaintRegion (DrawablePtr pDraw, RegionPtr pRgn, Pixel fg)
BoxPtr pBox = REGION_RECTS (pRgn);
int nBox = REGION_NUM_RECTS (pRgn);
rects = ALLOCATE_LOCAL (nBox * sizeof (xRectangle));
rects = xalloc (nBox * sizeof (xRectangle));
if (!rects)
goto bail0;
r = rects;
......@@ -1956,7 +1956,7 @@ KXVPaintRegion (DrawablePtr pDraw, RegionPtr pRgn, Pixel fg)
FreeScratchGC (pGC);
bail1:
DEALLOCATE_LOCAL (rects);
xfree (rects);
bail0:
;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment