mfb: Remove usage of alloca

Replace with heap-based allocations.
This commit is contained in:
Daniel Stone 2007-11-05 14:09:14 +00:00
parent be9ee17f96
commit f7d5c292e4
9 changed files with 81 additions and 81 deletions

View File

@ -351,7 +351,7 @@ int dstx, dsty;
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);
@ -370,7 +370,7 @@ int dstx, dsty;
if (pGC->planemask & 1) if (pGC->planemask & 1)
(*localDoBitBlt) (pSrcDrawable, pDstDrawable, pGC->alu, &rgnDst, pptSrc); (*localDoBitBlt) (pSrcDrawable, pDstDrawable, pGC->alu, &rgnDst, pptSrc);
DEALLOCATE_LOCAL(pptSrc); xfree(pptSrc);
} }
prgnExposed = NULL; prgnExposed = NULL;

View File

@ -119,13 +119,13 @@ MROP_NAME(mfbDoBitblt)(pSrc, pDst, alu, prgnDst, pptSrc)
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;
@ -163,16 +163,16 @@ MROP_NAME(mfbDoBitblt)(pSrc, pDst, alu, prgnDst, pptSrc)
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) DEALLOCATE_LOCAL(pptNew2); if (pptNew2) xfree(pptNew2);
if (pboxNew2) DEALLOCATE_LOCAL(pboxNew2); if (pboxNew2) xfree(pboxNew2);
if (pboxNew1) if (pboxNew1)
{ {
DEALLOCATE_LOCAL(pptNew1); xfree(pptNew1);
DEALLOCATE_LOCAL(pboxNew1); xfree(pboxNew1);
} }
return; return;
} }
@ -578,12 +578,12 @@ bits1 = *--psrc; --pdst; \
} }
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

@ -118,7 +118,7 @@ mfbPolyFillRect(pDrawable, pGC, nrectFill, prectInit)
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;
} }
@ -222,5 +222,5 @@ mfbPolyFillRect(pDrawable, pGC, nrectFill, prectInit)
if (pboxClipped != pboxClippedBase) if (pboxClipped != pboxClippedBase)
(*pfn) (pDrawable,pboxClipped-pboxClippedBase, pboxClippedBase, alu, ppix); (*pfn) (pDrawable,pboxClipped-pboxClippedBase, pboxClippedBase, alu, ppix);
if (pboxClippedBase != stackRects) if (pboxClippedBase != stackRects)
DEALLOCATE_LOCAL(pboxClippedBase); xfree(pboxClippedBase);
} }

View File

@ -111,12 +111,12 @@ mfbBlackSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
return; return;
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;
@ -151,8 +151,8 @@ mfbBlackSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
pwidth++; pwidth++;
ppt++; ppt++;
} }
DEALLOCATE_LOCAL(pptFree); xfree(pptFree);
DEALLOCATE_LOCAL(pwidthFree); xfree(pwidthFree);
} }
@ -183,12 +183,12 @@ mfbWhiteSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
return; return;
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;
@ -223,8 +223,8 @@ mfbWhiteSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
pwidth++; pwidth++;
ppt++; ppt++;
} }
DEALLOCATE_LOCAL(pptFree); xfree(pptFree);
DEALLOCATE_LOCAL(pwidthFree); xfree(pwidthFree);
} }
@ -255,12 +255,12 @@ mfbInvertSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
return; return;
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;
@ -295,8 +295,8 @@ mfbInvertSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
pwidth++; pwidth++;
ppt++; ppt++;
} }
DEALLOCATE_LOCAL(pptFree); xfree(pptFree);
DEALLOCATE_LOCAL(pwidthFree); xfree(pwidthFree);
} }
@ -330,12 +330,12 @@ mfbWhiteStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
return; return;
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;
@ -372,8 +372,8 @@ mfbWhiteStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
pwidth++; pwidth++;
ppt++; ppt++;
} }
DEALLOCATE_LOCAL(pptFree); xfree(pptFree);
DEALLOCATE_LOCAL(pwidthFree); xfree(pwidthFree);
} }
@ -407,12 +407,12 @@ mfbBlackStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
return; return;
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;
@ -449,8 +449,8 @@ mfbBlackStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
pwidth++; pwidth++;
ppt++; ppt++;
} }
DEALLOCATE_LOCAL(pptFree); xfree(pptFree);
DEALLOCATE_LOCAL(pwidthFree); xfree(pwidthFree);
} }
@ -484,12 +484,12 @@ mfbInvertStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
return; return;
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;
@ -526,8 +526,8 @@ mfbInvertStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
pwidth++; pwidth++;
ppt++; ppt++;
} }
DEALLOCATE_LOCAL(pptFree); xfree(pptFree);
DEALLOCATE_LOCAL(pwidthFree); xfree(pwidthFree);
} }
@ -603,12 +603,12 @@ mfbTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
return; return;
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;
@ -708,8 +708,8 @@ mfbTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
} }
break; break;
} }
DEALLOCATE_LOCAL(pptFree); xfree(pptFree);
DEALLOCATE_LOCAL(pwidthFree); xfree(pwidthFree);
} }
@ -746,12 +746,12 @@ mfbUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
return; return;
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;
@ -873,8 +873,8 @@ mfbUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
ppt++; ppt++;
pwidth++; pwidth++;
} }
DEALLOCATE_LOCAL(pptFree); xfree(pptFree);
DEALLOCATE_LOCAL(pwidthFree); xfree(pwidthFree);
} }
@ -912,12 +912,12 @@ mfbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
return; return;
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;
@ -1021,6 +1021,6 @@ mfbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
ppt++; ppt++;
pwidth++; pwidth++;
} }
DEALLOCATE_LOCAL(pptFree); xfree(pptFree);
DEALLOCATE_LOCAL(pwidthFree); xfree(pwidthFree);
} }

View File

@ -293,7 +293,7 @@ MFBIMAGEGLYPHBLT(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 = (TEXTPOS *)ALLOCATE_LOCAL(nglyph * sizeof(TEXTPOS)))) if(!(ppos = (TEXTPOS *)xalloc(nglyph * sizeof(TEXTPOS))))
return; return;
pdstBase = mfbScanlineNoBankSwitch(pdstBase, x, y, widthDst); pdstBase = mfbScanlineNoBankSwitch(pdstBase, x, y, widthDst);
@ -434,7 +434,7 @@ MFBIMAGEGLYPHBLT(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
} }
} /* for each glyph */ } /* for each glyph */
} /* while nbox-- */ } /* while nbox-- */
DEALLOCATE_LOCAL(ppos); xfree(ppos);
break; break;
} }
default: default:

View File

@ -253,13 +253,13 @@ mfbYRotatePixmap(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;
memmove(ptmp, pbase, nbyUp); /* save the low rows */ memmove(ptmp, pbase, nbyUp); /* save the low rows */
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

@ -254,7 +254,7 @@ MFBPOLYGLYPHBLT(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 = (TEXTPOS *)ALLOCATE_LOCAL(nglyph * sizeof(TEXTPOS)))) if(!(ppos = (TEXTPOS *)xalloc(nglyph * sizeof(TEXTPOS))))
return; return;
pdstBase = mfbScanlineNoBankSwitch(pdstBase, x, y, widthDst); pdstBase = mfbScanlineNoBankSwitch(pdstBase, x, y, widthDst);
@ -388,7 +388,7 @@ MFBPOLYGLYPHBLT(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
} }
} /* for each glyph */ } /* for each glyph */
} /* while nbox-- */ } /* while nbox-- */
DEALLOCATE_LOCAL(ppos); xfree(ppos);
break; break;
} }
default: default:

View File

@ -132,7 +132,7 @@ mfbSolidPP(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg)
if (!REGION_NIL(&rgnDst)) if (!REGION_NIL(&rgnDst))
{ {
i = REGION_NUM_RECTS(&rgnDst); i = REGION_NUM_RECTS(&rgnDst);
pptSrc = (DDXPointPtr)ALLOCATE_LOCAL(i * sizeof(DDXPointRec)); pptSrc = (DDXPointPtr)xalloc(i * sizeof(DDXPointRec));
if(pptSrc) if(pptSrc)
{ {
for (pbox = REGION_RECTS(&rgnDst), ppt = pptSrc; for (pbox = REGION_RECTS(&rgnDst), ppt = pptSrc;
@ -143,7 +143,7 @@ mfbSolidPP(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg)
ppt->y = pbox->y1 - yOrg; ppt->y = pbox->y1 - yOrg;
} }
mfbDoBitblt((DrawablePtr)pBitMap, pDrawable, alu, &rgnDst, pptSrc); mfbDoBitblt((DrawablePtr)pBitMap, pDrawable, alu, &rgnDst, pptSrc);
DEALLOCATE_LOCAL(pptSrc); xfree(pptSrc);
} }
} }
REGION_UNINIT(pGC->pScreen, &rgnDst); REGION_UNINIT(pGC->pScreen, &rgnDst);

View File

@ -150,7 +150,7 @@ mfbCopyWindow(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;
@ -162,6 +162,6 @@ mfbCopyWindow(pWin, ptOldOrg, prgnSrc)
mfbDoBitblt((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, mfbDoBitblt((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
GXcopy, prgnDst, pptSrc); GXcopy, prgnDst, pptSrc);
DEALLOCATE_LOCAL(pptSrc); xfree(pptSrc);
REGION_DESTROY(pWin->drawable.pScreen, prgnDst); REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
} }