afb: Remove usage of alloca
Replace with heap allocations.
This commit is contained in:
parent
ca75261bee
commit
683ee1776d
|
@ -279,7 +279,7 @@ afbBitBlt(register DrawablePtr pSrcDrawable, register DrawablePtr pDstDrawable,
|
|||
/* Do bit blitting */
|
||||
numRects = REGION_NUM_RECTS(&rgnDst);
|
||||
if (numRects && width && height) {
|
||||
if(!(pptSrc = (DDXPointPtr)ALLOCATE_LOCAL(numRects *
|
||||
if(!(pptSrc = (DDXPointPtr)xalloc(numRects *
|
||||
sizeof(DDXPointRec)))) {
|
||||
REGION_UNINIT(pGC->pScreen, &rgnDst);
|
||||
if (freeSrcClip)
|
||||
|
@ -296,7 +296,7 @@ afbBitBlt(register DrawablePtr pSrcDrawable, register DrawablePtr pDstDrawable,
|
|||
(*doBitBlt)(pSrcDrawable, pDstDrawable, pGC->alu, &rgnDst, pptSrc,
|
||||
planemask);
|
||||
|
||||
DEALLOCATE_LOCAL(pptSrc);
|
||||
xfree(pptSrc);
|
||||
}
|
||||
|
||||
prgnExposed = NULL;
|
||||
|
|
26
afb/afbblt.c
26
afb/afbblt.c
|
@ -132,12 +132,12 @@ MROP_NAME(afbDoBitblt)(pSrc, pDst, alu, prgnDst, pptSrc, planemask)
|
|||
|
||||
if (nbox > 1) {
|
||||
/* keep ordering in each band, reverse order of bands */
|
||||
pboxNew1 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec)*nbox);
|
||||
pboxNew1 = (BoxPtr)xalloc(sizeof(BoxRec)*nbox);
|
||||
if(!pboxNew1)
|
||||
return;
|
||||
pptNew1 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec)*nbox);
|
||||
pptNew1 = (DDXPointPtr)xalloc(sizeof(DDXPointRec)*nbox);
|
||||
if(!pptNew1) {
|
||||
DEALLOCATE_LOCAL(pboxNew1);
|
||||
xfree(pboxNew1);
|
||||
return;
|
||||
}
|
||||
pboxBase = pboxNext = pbox+nbox-1;
|
||||
|
@ -169,16 +169,16 @@ MROP_NAME(afbDoBitblt)(pSrc, pDst, alu, prgnDst, pptSrc, planemask)
|
|||
|
||||
if (nbox > 1) {
|
||||
/* reverse order of rects in each band */
|
||||
pboxNew2 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox);
|
||||
pptNew2 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox);
|
||||
pboxNew2 = (BoxPtr)xalloc(sizeof(BoxRec) * nbox);
|
||||
pptNew2 = (DDXPointPtr)xalloc(sizeof(DDXPointRec) * nbox);
|
||||
if(!pboxNew2 || !pptNew2) {
|
||||
if (pptNew2)
|
||||
DEALLOCATE_LOCAL(pptNew2);
|
||||
xfree(pptNew2);
|
||||
if (pboxNew2)
|
||||
DEALLOCATE_LOCAL(pboxNew2);
|
||||
xfree(pboxNew2);
|
||||
if (pboxNew1) {
|
||||
DEALLOCATE_LOCAL(pptNew1);
|
||||
DEALLOCATE_LOCAL(pboxNew1);
|
||||
xfree(pptNew1);
|
||||
xfree(pboxNew1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -553,11 +553,11 @@ bits1 = *--psrc; --pdst; \
|
|||
pptSrc++;
|
||||
}
|
||||
if (pboxNew2) {
|
||||
DEALLOCATE_LOCAL(pptNew2);
|
||||
DEALLOCATE_LOCAL(pboxNew2);
|
||||
xfree(pptNew2);
|
||||
xfree(pboxNew2);
|
||||
}
|
||||
if (pboxNew1) {
|
||||
DEALLOCATE_LOCAL(pptNew1);
|
||||
DEALLOCATE_LOCAL(pboxNew1);
|
||||
xfree(pptNew1);
|
||||
xfree(pboxNew1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ afbPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, xRectangle *pre
|
|||
|
||||
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;
|
||||
}
|
||||
|
@ -287,5 +287,5 @@ afbPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, xRectangle *pre
|
|||
}
|
||||
}
|
||||
if (pboxClippedBase != stackRects)
|
||||
DEALLOCATE_LOCAL(pboxClippedBase);
|
||||
xfree(pboxClippedBase);
|
||||
}
|
||||
|
|
|
@ -109,11 +109,11 @@ afbSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
|
|||
unsigned char *rrops;
|
||||
|
||||
n = nInit * miFindMaxBand(pGC->pCompositeClip);
|
||||
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
|
||||
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
|
||||
pwidthFree = (int *)xalloc(n * sizeof(int));
|
||||
pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
|
||||
if(!pptFree || !pwidthFree) {
|
||||
if (pptFree) DEALLOCATE_LOCAL(pptFree);
|
||||
if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
|
||||
if (pptFree) xfree(pptFree);
|
||||
if (pwidthFree) xfree(pwidthFree);
|
||||
return;
|
||||
}
|
||||
pwidth = pwidthFree;
|
||||
|
@ -183,8 +183,8 @@ afbSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
|
|||
pwidth++;
|
||||
ppt++;
|
||||
}
|
||||
DEALLOCATE_LOCAL(pptFree);
|
||||
DEALLOCATE_LOCAL(pwidthFree);
|
||||
xfree(pptFree);
|
||||
xfree(pwidthFree);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -219,11 +219,11 @@ afbStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
|
|||
unsigned char *rrops;
|
||||
|
||||
n = nInit * miFindMaxBand(pGC->pCompositeClip);
|
||||
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
|
||||
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
|
||||
pwidthFree = (int *)xalloc(n * sizeof(int));
|
||||
pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
|
||||
if(!pptFree || !pwidthFree) {
|
||||
if (pptFree) DEALLOCATE_LOCAL(pptFree);
|
||||
if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
|
||||
if (pptFree) xfree(pptFree);
|
||||
if (pwidthFree) xfree(pwidthFree);
|
||||
return;
|
||||
}
|
||||
pwidth = pwidthFree;
|
||||
|
@ -297,8 +297,8 @@ afbStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
|
|||
pwidth++;
|
||||
ppt++;
|
||||
}
|
||||
DEALLOCATE_LOCAL(pptFree);
|
||||
DEALLOCATE_LOCAL(pwidthFree);
|
||||
xfree(pptFree);
|
||||
xfree(pwidthFree);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -333,11 +333,11 @@ afbTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
|
|||
int d;
|
||||
|
||||
n = nInit * miFindMaxBand(pGC->pCompositeClip);
|
||||
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
|
||||
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
|
||||
pwidthFree = (int *)xalloc(n * sizeof(int));
|
||||
pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
|
||||
if(!pptFree || !pwidthFree) {
|
||||
if (pptFree) DEALLOCATE_LOCAL(pptFree);
|
||||
if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
|
||||
if (pptFree) xfree(pptFree);
|
||||
if (pwidthFree) xfree(pwidthFree);
|
||||
return;
|
||||
}
|
||||
pwidth = pwidthFree;
|
||||
|
@ -428,8 +428,8 @@ afbTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
|
|||
break;
|
||||
}
|
||||
}
|
||||
DEALLOCATE_LOCAL(pptFree);
|
||||
DEALLOCATE_LOCAL(pwidthFree);
|
||||
xfree(pptFree);
|
||||
xfree(pwidthFree);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -465,11 +465,11 @@ afbOpaqueStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
|
|||
int d;
|
||||
|
||||
n = nInit * miFindMaxBand(pGC->pCompositeClip);
|
||||
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
|
||||
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
|
||||
pwidthFree = (int *)xalloc(n * sizeof(int));
|
||||
pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
|
||||
if(!pptFree || !pwidthFree) {
|
||||
if (pptFree) DEALLOCATE_LOCAL(pptFree);
|
||||
if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
|
||||
if (pptFree) xfree(pptFree);
|
||||
if (pwidthFree) xfree(pwidthFree);
|
||||
return;
|
||||
}
|
||||
pwidth = pwidthFree;
|
||||
|
@ -587,8 +587,8 @@ afbOpaqueStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
|
|||
break;
|
||||
}
|
||||
} /* switch (rop) */
|
||||
DEALLOCATE_LOCAL(pptFree);
|
||||
DEALLOCATE_LOCAL(pwidthFree);
|
||||
xfree(pptFree);
|
||||
xfree(pwidthFree);
|
||||
}
|
||||
|
||||
/* Fill spans with tiles that aren't PPW bits wide */
|
||||
|
@ -626,11 +626,11 @@ afbUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
|
|||
register int d;
|
||||
|
||||
n = nInit * miFindMaxBand(pGC->pCompositeClip);
|
||||
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
|
||||
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
|
||||
pwidthFree = (int *)xalloc(n * sizeof(int));
|
||||
pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
|
||||
if(!pptFree || !pwidthFree) {
|
||||
if (pptFree) DEALLOCATE_LOCAL(pptFree);
|
||||
if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
|
||||
if (pptFree) xfree(pptFree);
|
||||
if (pwidthFree) xfree(pwidthFree);
|
||||
return;
|
||||
}
|
||||
pwidth = pwidthFree;
|
||||
|
@ -732,8 +732,8 @@ afbUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
|
|||
ppt++;
|
||||
pwidth++;
|
||||
}
|
||||
DEALLOCATE_LOCAL(pptFree);
|
||||
DEALLOCATE_LOCAL(pwidthFree);
|
||||
xfree(pptFree);
|
||||
xfree(pwidthFree);
|
||||
}
|
||||
|
||||
/* Fill spans with stipples that aren't PPW bits wide */
|
||||
|
@ -772,11 +772,11 @@ afbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
|
|||
int depthDst;
|
||||
|
||||
n = nInit * miFindMaxBand(pGC->pCompositeClip);
|
||||
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
|
||||
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
|
||||
pwidthFree = (int *)xalloc(n * sizeof(int));
|
||||
pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
|
||||
if(!pptFree || !pwidthFree) {
|
||||
if (pptFree) DEALLOCATE_LOCAL(pptFree);
|
||||
if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
|
||||
if (pptFree) xfree(pptFree);
|
||||
if (pwidthFree) xfree(pwidthFree);
|
||||
return;
|
||||
}
|
||||
pwidth = pwidthFree;
|
||||
|
@ -877,8 +877,8 @@ afbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
|
|||
ppt++;
|
||||
pwidth++;
|
||||
}
|
||||
DEALLOCATE_LOCAL(pptFree);
|
||||
DEALLOCATE_LOCAL(pwidthFree);
|
||||
xfree(pptFree);
|
||||
xfree(pwidthFree);
|
||||
}
|
||||
|
||||
/* Fill spans with OpaqueStipples that aren't PPW bits wide */
|
||||
|
@ -918,11 +918,11 @@ afbUnnaturalOpaqueStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
|
|||
int depthDst;
|
||||
|
||||
n = nInit * miFindMaxBand(pGC->pCompositeClip);
|
||||
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
|
||||
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
|
||||
pwidthFree = (int *)xalloc(n * sizeof(int));
|
||||
pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
|
||||
if(!pptFree || !pwidthFree) {
|
||||
if (pptFree) DEALLOCATE_LOCAL(pptFree);
|
||||
if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
|
||||
if (pptFree) xfree(pptFree);
|
||||
if (pwidthFree) xfree(pwidthFree);
|
||||
return;
|
||||
}
|
||||
pwidth = pwidthFree;
|
||||
|
@ -1124,6 +1124,6 @@ afbUnnaturalOpaqueStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
|
|||
ppt++;
|
||||
pwidth++;
|
||||
}
|
||||
DEALLOCATE_LOCAL(pptFree);
|
||||
DEALLOCATE_LOCAL(pwidthFree);
|
||||
xfree(pptFree);
|
||||
xfree(pwidthFree);
|
||||
}
|
||||
|
|
|
@ -298,7 +298,7 @@ afbImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
|
|||
int getWidth; /* bits to get from glyph */
|
||||
#endif
|
||||
|
||||
if(!(ppos = (afbTEXTPOS *)ALLOCATE_LOCAL(nglyph * sizeof(afbTEXTPOS))))
|
||||
if(!(ppos = (afbTEXTPOS *)xalloc(nglyph * sizeof(afbTEXTPOS))))
|
||||
return;
|
||||
|
||||
pdstBase = afbScanlineNoBankSwitch(pdstBase, x, y, widthDst);
|
||||
|
@ -462,7 +462,7 @@ afbImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
|
|||
} /* depth */
|
||||
} /* for each glyph */
|
||||
} /* while nbox-- */
|
||||
DEALLOCATE_LOCAL(ppos);
|
||||
xfree(ppos);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -251,7 +251,7 @@ afbYRotatePixmap(pPix, rh)
|
|||
nbyDown = rh * pPix->devKind;
|
||||
nbyUp = (pPix->devKind * height) - nbyDown;
|
||||
|
||||
if(!(ptmp = (char *)ALLOCATE_LOCAL(nbyUp)))
|
||||
if(!(ptmp = (char *)xalloc(nbyUp)))
|
||||
return;
|
||||
|
||||
for (d = 0; d < pPix->drawable.depth; d++) {
|
||||
|
@ -261,7 +261,7 @@ afbYRotatePixmap(pPix, rh)
|
|||
memmove(pbase, pbase+nbyUp, nbyDown); /* slide the top rows down */
|
||||
memmove(pbase+nbyDown, ptmp, nbyUp); /* move lower rows up to row rh */
|
||||
}
|
||||
DEALLOCATE_LOCAL(ptmp);
|
||||
xfree(ptmp);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -278,7 +278,7 @@ afbPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
|
|||
int getWidth; /* bits to get from glyph */
|
||||
#endif
|
||||
|
||||
if(!(ppos = (afbTEXTPOS *)ALLOCATE_LOCAL(nglyph * sizeof(afbTEXTPOS))))
|
||||
if(!(ppos = (afbTEXTPOS *)xalloc(nglyph * sizeof(afbTEXTPOS))))
|
||||
return;
|
||||
|
||||
pdstBase = afbScanlineNoBankSwitch(pdstBase, x, y, widthDst);
|
||||
|
@ -453,7 +453,7 @@ afbPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
|
|||
} /* depth */
|
||||
} /* for each glyph */
|
||||
} /* while nbox-- */
|
||||
DEALLOCATE_LOCAL(ppos);
|
||||
xfree(ppos);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ afbCopyWindow(pWin, ptOldOrg, prgnSrc)
|
|||
|
||||
pbox = REGION_RECTS(prgnDst);
|
||||
nbox = REGION_NUM_RECTS(prgnDst);
|
||||
if(!(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec))))
|
||||
if(!(pptSrc = (DDXPointPtr )xalloc(nbox * sizeof(DDXPointRec))))
|
||||
return;
|
||||
ppt = pptSrc;
|
||||
|
||||
|
@ -152,7 +152,7 @@ afbCopyWindow(pWin, ptOldOrg, prgnSrc)
|
|||
|
||||
afbDoBitblt((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, GXcopy, prgnDst,
|
||||
pptSrc, ~0);
|
||||
DEALLOCATE_LOCAL(pptSrc);
|
||||
xfree(pptSrc);
|
||||
REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue