afb: Remove usage of alloca

Replace with heap allocations.
This commit is contained in:
Daniel Stone 2007-11-05 14:14:25 +00:00
parent ca75261bee
commit 683ee1776d
8 changed files with 67 additions and 67 deletions

View File

@ -279,7 +279,7 @@ afbBitBlt(register DrawablePtr pSrcDrawable, register DrawablePtr pDstDrawable,
/* Do bit blitting */ /* Do bit blitting */
numRects = REGION_NUM_RECTS(&rgnDst); numRects = REGION_NUM_RECTS(&rgnDst);
if (numRects && width && height) { if (numRects && width && height) {
if(!(pptSrc = (DDXPointPtr)ALLOCATE_LOCAL(numRects * if(!(pptSrc = (DDXPointPtr)xalloc(numRects *
sizeof(DDXPointRec)))) { sizeof(DDXPointRec)))) {
REGION_UNINIT(pGC->pScreen, &rgnDst); REGION_UNINIT(pGC->pScreen, &rgnDst);
if (freeSrcClip) if (freeSrcClip)
@ -296,7 +296,7 @@ afbBitBlt(register DrawablePtr pSrcDrawable, register DrawablePtr pDstDrawable,
(*doBitBlt)(pSrcDrawable, pDstDrawable, pGC->alu, &rgnDst, pptSrc, (*doBitBlt)(pSrcDrawable, pDstDrawable, pGC->alu, &rgnDst, pptSrc,
planemask); planemask);
DEALLOCATE_LOCAL(pptSrc); xfree(pptSrc);
} }
prgnExposed = NULL; prgnExposed = NULL;

View File

@ -132,12 +132,12 @@ MROP_NAME(afbDoBitblt)(pSrc, pDst, alu, prgnDst, pptSrc, planemask)
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)ALLOCATE_LOCAL(sizeof(BoxRec)*nbox); pboxNew1 = (BoxPtr)xalloc(sizeof(BoxRec)*nbox);
if(!pboxNew1) if(!pboxNew1)
return; return;
pptNew1 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec)*nbox); pptNew1 = (DDXPointPtr)xalloc(sizeof(DDXPointRec)*nbox);
if(!pptNew1) { if(!pptNew1) {
DEALLOCATE_LOCAL(pboxNew1); xfree(pboxNew1);
return; return;
} }
pboxBase = pboxNext = pbox+nbox-1; pboxBase = pboxNext = pbox+nbox-1;
@ -169,16 +169,16 @@ MROP_NAME(afbDoBitblt)(pSrc, pDst, alu, prgnDst, pptSrc, planemask)
if (nbox > 1) { if (nbox > 1) {
/* reverse order of rects in each band */ /* reverse order of rects in each band */
pboxNew2 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox); pboxNew2 = (BoxPtr)xalloc(sizeof(BoxRec) * nbox);
pptNew2 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox); pptNew2 = (DDXPointPtr)xalloc(sizeof(DDXPointRec) * nbox);
if(!pboxNew2 || !pptNew2) { if(!pboxNew2 || !pptNew2) {
if (pptNew2) if (pptNew2)
DEALLOCATE_LOCAL(pptNew2); xfree(pptNew2);
if (pboxNew2) if (pboxNew2)
DEALLOCATE_LOCAL(pboxNew2); xfree(pboxNew2);
if (pboxNew1) { if (pboxNew1) {
DEALLOCATE_LOCAL(pptNew1); xfree(pptNew1);
DEALLOCATE_LOCAL(pboxNew1); xfree(pboxNew1);
} }
return; return;
} }
@ -553,11 +553,11 @@ bits1 = *--psrc; --pdst; \
pptSrc++; pptSrc++;
} }
if (pboxNew2) { if (pboxNew2) {
DEALLOCATE_LOCAL(pptNew2); xfree(pptNew2);
DEALLOCATE_LOCAL(pboxNew2); xfree(pboxNew2);
} }
if (pboxNew1) { if (pboxNew1) {
DEALLOCATE_LOCAL(pptNew1); xfree(pptNew1);
DEALLOCATE_LOCAL(pboxNew1); xfree(pboxNew1);
} }
} }

View File

@ -111,7 +111,7 @@ afbPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, xRectangle *pre
numRects = REGION_NUM_RECTS(prgnClip) * nrectFill; numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
if (numRects > NUM_STACK_RECTS) { if (numRects > NUM_STACK_RECTS) {
pboxClippedBase = (BoxPtr)ALLOCATE_LOCAL(numRects * sizeof(BoxRec)); pboxClippedBase = (BoxPtr)xalloc(numRects * sizeof(BoxRec));
if (!pboxClippedBase) if (!pboxClippedBase)
return; return;
} }
@ -287,5 +287,5 @@ afbPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, xRectangle *pre
} }
} }
if (pboxClippedBase != stackRects) if (pboxClippedBase != stackRects)
DEALLOCATE_LOCAL(pboxClippedBase); xfree(pboxClippedBase);
} }

View File

@ -109,11 +109,11 @@ afbSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
unsigned char *rrops; unsigned char *rrops;
n = nInit * miFindMaxBand(pGC->pCompositeClip); n = nInit * miFindMaxBand(pGC->pCompositeClip);
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int)); pwidthFree = (int *)xalloc(n * sizeof(int));
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec)); pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
if(!pptFree || !pwidthFree) { if(!pptFree || !pwidthFree) {
if (pptFree) DEALLOCATE_LOCAL(pptFree); if (pptFree) xfree(pptFree);
if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree); if (pwidthFree) xfree(pwidthFree);
return; return;
} }
pwidth = pwidthFree; pwidth = pwidthFree;
@ -183,8 +183,8 @@ afbSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
pwidth++; pwidth++;
ppt++; ppt++;
} }
DEALLOCATE_LOCAL(pptFree); xfree(pptFree);
DEALLOCATE_LOCAL(pwidthFree); xfree(pwidthFree);
} }
void void
@ -219,11 +219,11 @@ afbStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
unsigned char *rrops; unsigned char *rrops;
n = nInit * miFindMaxBand(pGC->pCompositeClip); n = nInit * miFindMaxBand(pGC->pCompositeClip);
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int)); pwidthFree = (int *)xalloc(n * sizeof(int));
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec)); pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
if(!pptFree || !pwidthFree) { if(!pptFree || !pwidthFree) {
if (pptFree) DEALLOCATE_LOCAL(pptFree); if (pptFree) xfree(pptFree);
if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree); if (pwidthFree) xfree(pwidthFree);
return; return;
} }
pwidth = pwidthFree; pwidth = pwidthFree;
@ -297,8 +297,8 @@ afbStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
pwidth++; pwidth++;
ppt++; ppt++;
} }
DEALLOCATE_LOCAL(pptFree); xfree(pptFree);
DEALLOCATE_LOCAL(pwidthFree); xfree(pwidthFree);
} }
void void
@ -333,11 +333,11 @@ afbTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
int d; int d;
n = nInit * miFindMaxBand(pGC->pCompositeClip); n = nInit * miFindMaxBand(pGC->pCompositeClip);
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int)); pwidthFree = (int *)xalloc(n * sizeof(int));
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec)); pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
if(!pptFree || !pwidthFree) { if(!pptFree || !pwidthFree) {
if (pptFree) DEALLOCATE_LOCAL(pptFree); if (pptFree) xfree(pptFree);
if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree); if (pwidthFree) xfree(pwidthFree);
return; return;
} }
pwidth = pwidthFree; pwidth = pwidthFree;
@ -428,8 +428,8 @@ afbTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
break; break;
} }
} }
DEALLOCATE_LOCAL(pptFree); xfree(pptFree);
DEALLOCATE_LOCAL(pwidthFree); xfree(pwidthFree);
} }
void void
@ -465,11 +465,11 @@ afbOpaqueStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
int d; int d;
n = nInit * miFindMaxBand(pGC->pCompositeClip); n = nInit * miFindMaxBand(pGC->pCompositeClip);
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int)); pwidthFree = (int *)xalloc(n * sizeof(int));
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec)); pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
if(!pptFree || !pwidthFree) { if(!pptFree || !pwidthFree) {
if (pptFree) DEALLOCATE_LOCAL(pptFree); if (pptFree) xfree(pptFree);
if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree); if (pwidthFree) xfree(pwidthFree);
return; return;
} }
pwidth = pwidthFree; pwidth = pwidthFree;
@ -587,8 +587,8 @@ afbOpaqueStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
break; break;
} }
} /* switch (rop) */ } /* switch (rop) */
DEALLOCATE_LOCAL(pptFree); xfree(pptFree);
DEALLOCATE_LOCAL(pwidthFree); xfree(pwidthFree);
} }
/* Fill spans with tiles that aren't PPW bits wide */ /* Fill spans with tiles that aren't PPW bits wide */
@ -626,11 +626,11 @@ afbUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
register int d; register int d;
n = nInit * miFindMaxBand(pGC->pCompositeClip); n = nInit * miFindMaxBand(pGC->pCompositeClip);
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int)); pwidthFree = (int *)xalloc(n * sizeof(int));
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec)); pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
if(!pptFree || !pwidthFree) { if(!pptFree || !pwidthFree) {
if (pptFree) DEALLOCATE_LOCAL(pptFree); if (pptFree) xfree(pptFree);
if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree); if (pwidthFree) xfree(pwidthFree);
return; return;
} }
pwidth = pwidthFree; pwidth = pwidthFree;
@ -732,8 +732,8 @@ afbUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
ppt++; ppt++;
pwidth++; pwidth++;
} }
DEALLOCATE_LOCAL(pptFree); xfree(pptFree);
DEALLOCATE_LOCAL(pwidthFree); xfree(pwidthFree);
} }
/* Fill spans with stipples that aren't PPW bits wide */ /* Fill spans with stipples that aren't PPW bits wide */
@ -772,11 +772,11 @@ afbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
int depthDst; int depthDst;
n = nInit * miFindMaxBand(pGC->pCompositeClip); n = nInit * miFindMaxBand(pGC->pCompositeClip);
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int)); pwidthFree = (int *)xalloc(n * sizeof(int));
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec)); pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
if(!pptFree || !pwidthFree) { if(!pptFree || !pwidthFree) {
if (pptFree) DEALLOCATE_LOCAL(pptFree); if (pptFree) xfree(pptFree);
if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree); if (pwidthFree) xfree(pwidthFree);
return; return;
} }
pwidth = pwidthFree; pwidth = pwidthFree;
@ -877,8 +877,8 @@ afbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
ppt++; ppt++;
pwidth++; pwidth++;
} }
DEALLOCATE_LOCAL(pptFree); xfree(pptFree);
DEALLOCATE_LOCAL(pwidthFree); xfree(pwidthFree);
} }
/* Fill spans with OpaqueStipples that aren't PPW bits wide */ /* Fill spans with OpaqueStipples that aren't PPW bits wide */
@ -918,11 +918,11 @@ afbUnnaturalOpaqueStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
int depthDst; int depthDst;
n = nInit * miFindMaxBand(pGC->pCompositeClip); n = nInit * miFindMaxBand(pGC->pCompositeClip);
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int)); pwidthFree = (int *)xalloc(n * sizeof(int));
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec)); pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
if(!pptFree || !pwidthFree) { if(!pptFree || !pwidthFree) {
if (pptFree) DEALLOCATE_LOCAL(pptFree); if (pptFree) xfree(pptFree);
if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree); if (pwidthFree) xfree(pwidthFree);
return; return;
} }
pwidth = pwidthFree; pwidth = pwidthFree;
@ -1124,6 +1124,6 @@ afbUnnaturalOpaqueStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
ppt++; ppt++;
pwidth++; pwidth++;
} }
DEALLOCATE_LOCAL(pptFree); xfree(pptFree);
DEALLOCATE_LOCAL(pwidthFree); xfree(pwidthFree);
} }

View File

@ -298,7 +298,7 @@ afbImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
int getWidth; /* bits to get from glyph */ int getWidth; /* bits to get from glyph */
#endif #endif
if(!(ppos = (afbTEXTPOS *)ALLOCATE_LOCAL(nglyph * sizeof(afbTEXTPOS)))) if(!(ppos = (afbTEXTPOS *)xalloc(nglyph * sizeof(afbTEXTPOS))))
return; return;
pdstBase = afbScanlineNoBankSwitch(pdstBase, x, y, widthDst); pdstBase = afbScanlineNoBankSwitch(pdstBase, x, y, widthDst);
@ -462,7 +462,7 @@ afbImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
} /* depth */ } /* depth */
} /* for each glyph */ } /* for each glyph */
} /* while nbox-- */ } /* while nbox-- */
DEALLOCATE_LOCAL(ppos); xfree(ppos);
break; break;
} }

View File

@ -251,7 +251,7 @@ afbYRotatePixmap(pPix, rh)
nbyDown = rh * pPix->devKind; nbyDown = rh * pPix->devKind;
nbyUp = (pPix->devKind * height) - nbyDown; nbyUp = (pPix->devKind * height) - nbyDown;
if(!(ptmp = (char *)ALLOCATE_LOCAL(nbyUp))) if(!(ptmp = (char *)xalloc(nbyUp)))
return; return;
for (d = 0; d < pPix->drawable.depth; d++) { 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, pbase+nbyUp, nbyDown); /* slide the top rows down */
memmove(pbase+nbyDown, ptmp, nbyUp); /* move lower rows up to row rh */ memmove(pbase+nbyDown, ptmp, nbyUp); /* move lower rows up to row rh */
} }
DEALLOCATE_LOCAL(ptmp); xfree(ptmp);
} }
void void

View File

@ -278,7 +278,7 @@ afbPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
int getWidth; /* bits to get from glyph */ int getWidth; /* bits to get from glyph */
#endif #endif
if(!(ppos = (afbTEXTPOS *)ALLOCATE_LOCAL(nglyph * sizeof(afbTEXTPOS)))) if(!(ppos = (afbTEXTPOS *)xalloc(nglyph * sizeof(afbTEXTPOS))))
return; return;
pdstBase = afbScanlineNoBankSwitch(pdstBase, x, y, widthDst); pdstBase = afbScanlineNoBankSwitch(pdstBase, x, y, widthDst);
@ -453,7 +453,7 @@ afbPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
} /* depth */ } /* depth */
} /* for each glyph */ } /* for each glyph */
} /* while nbox-- */ } /* while nbox-- */
DEALLOCATE_LOCAL(ppos); xfree(ppos);
break; break;
} }

View File

@ -141,7 +141,7 @@ afbCopyWindow(pWin, ptOldOrg, prgnSrc)
pbox = REGION_RECTS(prgnDst); pbox = REGION_RECTS(prgnDst);
nbox = REGION_NUM_RECTS(prgnDst); nbox = REGION_NUM_RECTS(prgnDst);
if(!(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec)))) if(!(pptSrc = (DDXPointPtr )xalloc(nbox * sizeof(DDXPointRec))))
return; return;
ppt = pptSrc; ppt = pptSrc;
@ -152,7 +152,7 @@ afbCopyWindow(pWin, ptOldOrg, prgnSrc)
afbDoBitblt((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, GXcopy, prgnDst, afbDoBitblt((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, GXcopy, prgnDst,
pptSrc, ~0); pptSrc, ~0);
DEALLOCATE_LOCAL(pptSrc); xfree(pptSrc);
REGION_DESTROY(pWin->drawable.pScreen, prgnDst); REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
} }