From f7d5c292e44113ea8eb32e67e91cd02e520df5e3 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Mon, 5 Nov 2007 14:09:14 +0000 Subject: [PATCH] mfb: Remove usage of alloca Replace with heap-based allocations. --- mfb/mfbbitblt.c | 4 +- mfb/mfbblt.c | 26 ++++++------ mfb/mfbfillrct.c | 4 +- mfb/mfbfillsp.c | 108 +++++++++++++++++++++++------------------------ mfb/mfbimggblt.c | 4 +- mfb/mfbpixmap.c | 4 +- mfb/mfbplygblt.c | 4 +- mfb/mfbpushpxl.c | 4 +- mfb/mfbwindow.c | 4 +- 9 files changed, 81 insertions(+), 81 deletions(-) diff --git a/mfb/mfbbitblt.c b/mfb/mfbbitblt.c index 0f84df354..153cf6ac6 100644 --- a/mfb/mfbbitblt.c +++ b/mfb/mfbbitblt.c @@ -351,7 +351,7 @@ int dstx, dsty; 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); @@ -370,7 +370,7 @@ int dstx, dsty; if (pGC->planemask & 1) (*localDoBitBlt) (pSrcDrawable, pDstDrawable, pGC->alu, &rgnDst, pptSrc); - DEALLOCATE_LOCAL(pptSrc); + xfree(pptSrc); } prgnExposed = NULL; diff --git a/mfb/mfbblt.c b/mfb/mfbblt.c index 4c3028126..b87a69797 100644 --- a/mfb/mfbblt.c +++ b/mfb/mfbblt.c @@ -119,13 +119,13 @@ MROP_NAME(mfbDoBitblt)(pSrc, pDst, alu, prgnDst, pptSrc) 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; @@ -163,16 +163,16 @@ MROP_NAME(mfbDoBitblt)(pSrc, pDst, alu, prgnDst, pptSrc) 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); - if (pboxNew2) DEALLOCATE_LOCAL(pboxNew2); + if (pptNew2) xfree(pptNew2); + if (pboxNew2) xfree(pboxNew2); if (pboxNew1) { - DEALLOCATE_LOCAL(pptNew1); - DEALLOCATE_LOCAL(pboxNew1); + xfree(pptNew1); + xfree(pboxNew1); } return; } @@ -578,12 +578,12 @@ bits1 = *--psrc; --pdst; \ } if (pboxNew2) { - DEALLOCATE_LOCAL(pptNew2); - DEALLOCATE_LOCAL(pboxNew2); + xfree(pptNew2); + xfree(pboxNew2); } if (pboxNew1) { - DEALLOCATE_LOCAL(pptNew1); - DEALLOCATE_LOCAL(pboxNew1); + xfree(pptNew1); + xfree(pboxNew1); } } diff --git a/mfb/mfbfillrct.c b/mfb/mfbfillrct.c index f9209d096..594c7f01b 100644 --- a/mfb/mfbfillrct.c +++ b/mfb/mfbfillrct.c @@ -118,7 +118,7 @@ mfbPolyFillRect(pDrawable, pGC, nrectFill, prectInit) 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; } @@ -222,5 +222,5 @@ mfbPolyFillRect(pDrawable, pGC, nrectFill, prectInit) if (pboxClipped != pboxClippedBase) (*pfn) (pDrawable,pboxClipped-pboxClippedBase, pboxClippedBase, alu, ppix); if (pboxClippedBase != stackRects) - DEALLOCATE_LOCAL(pboxClippedBase); + xfree(pboxClippedBase); } diff --git a/mfb/mfbfillsp.c b/mfb/mfbfillsp.c index 112f5327c..f83ca6a54 100644 --- a/mfb/mfbfillsp.c +++ b/mfb/mfbfillsp.c @@ -111,12 +111,12 @@ mfbBlackSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) return; 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; @@ -151,8 +151,8 @@ mfbBlackSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) pwidth++; ppt++; } - DEALLOCATE_LOCAL(pptFree); - DEALLOCATE_LOCAL(pwidthFree); + xfree(pptFree); + xfree(pwidthFree); } @@ -183,12 +183,12 @@ mfbWhiteSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) return; 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; @@ -223,8 +223,8 @@ mfbWhiteSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) pwidth++; ppt++; } - DEALLOCATE_LOCAL(pptFree); - DEALLOCATE_LOCAL(pwidthFree); + xfree(pptFree); + xfree(pwidthFree); } @@ -255,12 +255,12 @@ mfbInvertSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) return; 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; @@ -295,8 +295,8 @@ mfbInvertSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) pwidth++; ppt++; } - DEALLOCATE_LOCAL(pptFree); - DEALLOCATE_LOCAL(pwidthFree); + xfree(pptFree); + xfree(pwidthFree); } @@ -330,12 +330,12 @@ mfbWhiteStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) return; 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; @@ -372,8 +372,8 @@ mfbWhiteStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) pwidth++; ppt++; } - DEALLOCATE_LOCAL(pptFree); - DEALLOCATE_LOCAL(pwidthFree); + xfree(pptFree); + xfree(pwidthFree); } @@ -407,12 +407,12 @@ mfbBlackStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) return; 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; @@ -449,8 +449,8 @@ mfbBlackStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) pwidth++; ppt++; } - DEALLOCATE_LOCAL(pptFree); - DEALLOCATE_LOCAL(pwidthFree); + xfree(pptFree); + xfree(pwidthFree); } @@ -484,12 +484,12 @@ mfbInvertStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) return; 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; @@ -526,8 +526,8 @@ mfbInvertStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) pwidth++; ppt++; } - DEALLOCATE_LOCAL(pptFree); - DEALLOCATE_LOCAL(pwidthFree); + xfree(pptFree); + xfree(pwidthFree); } @@ -603,12 +603,12 @@ mfbTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) return; 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; @@ -708,8 +708,8 @@ mfbTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) } break; } - DEALLOCATE_LOCAL(pptFree); - DEALLOCATE_LOCAL(pwidthFree); + xfree(pptFree); + xfree(pwidthFree); } @@ -746,12 +746,12 @@ mfbUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) return; 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; @@ -873,8 +873,8 @@ mfbUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) ppt++; pwidth++; } - DEALLOCATE_LOCAL(pptFree); - DEALLOCATE_LOCAL(pwidthFree); + xfree(pptFree); + xfree(pwidthFree); } @@ -912,12 +912,12 @@ mfbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) return; 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; @@ -1021,6 +1021,6 @@ mfbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) ppt++; pwidth++; } - DEALLOCATE_LOCAL(pptFree); - DEALLOCATE_LOCAL(pwidthFree); + xfree(pptFree); + xfree(pwidthFree); } diff --git a/mfb/mfbimggblt.c b/mfb/mfbimggblt.c index e5c186b89..c21e82608 100644 --- a/mfb/mfbimggblt.c +++ b/mfb/mfbimggblt.c @@ -293,7 +293,7 @@ MFBIMAGEGLYPHBLT(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) int getWidth; /* bits to get from glyph */ #endif - if(!(ppos = (TEXTPOS *)ALLOCATE_LOCAL(nglyph * sizeof(TEXTPOS)))) + if(!(ppos = (TEXTPOS *)xalloc(nglyph * sizeof(TEXTPOS)))) return; pdstBase = mfbScanlineNoBankSwitch(pdstBase, x, y, widthDst); @@ -434,7 +434,7 @@ MFBIMAGEGLYPHBLT(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) } } /* for each glyph */ } /* while nbox-- */ - DEALLOCATE_LOCAL(ppos); + xfree(ppos); break; } default: diff --git a/mfb/mfbpixmap.c b/mfb/mfbpixmap.c index 1472b44e2..438e9ab57 100644 --- a/mfb/mfbpixmap.c +++ b/mfb/mfbpixmap.c @@ -253,13 +253,13 @@ mfbYRotatePixmap(pPix, rh) nbyDown = rh * pPix->devKind; nbyUp = (pPix->devKind * height) - nbyDown; - if(!(ptmp = (char *)ALLOCATE_LOCAL(nbyUp))) + if(!(ptmp = (char *)xalloc(nbyUp))) return; memmove(ptmp, pbase, nbyUp); /* save the low rows */ 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 diff --git a/mfb/mfbplygblt.c b/mfb/mfbplygblt.c index 997e4a388..1bd56e1ec 100644 --- a/mfb/mfbplygblt.c +++ b/mfb/mfbplygblt.c @@ -254,7 +254,7 @@ MFBPOLYGLYPHBLT(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) int getWidth; /* bits to get from glyph */ #endif - if(!(ppos = (TEXTPOS *)ALLOCATE_LOCAL(nglyph * sizeof(TEXTPOS)))) + if(!(ppos = (TEXTPOS *)xalloc(nglyph * sizeof(TEXTPOS)))) return; pdstBase = mfbScanlineNoBankSwitch(pdstBase, x, y, widthDst); @@ -388,7 +388,7 @@ MFBPOLYGLYPHBLT(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) } } /* for each glyph */ } /* while nbox-- */ - DEALLOCATE_LOCAL(ppos); + xfree(ppos); break; } default: diff --git a/mfb/mfbpushpxl.c b/mfb/mfbpushpxl.c index ddf7b3c0e..de9699252 100644 --- a/mfb/mfbpushpxl.c +++ b/mfb/mfbpushpxl.c @@ -132,7 +132,7 @@ mfbSolidPP(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg) if (!REGION_NIL(&rgnDst)) { i = REGION_NUM_RECTS(&rgnDst); - pptSrc = (DDXPointPtr)ALLOCATE_LOCAL(i * sizeof(DDXPointRec)); + pptSrc = (DDXPointPtr)xalloc(i * sizeof(DDXPointRec)); if(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; } mfbDoBitblt((DrawablePtr)pBitMap, pDrawable, alu, &rgnDst, pptSrc); - DEALLOCATE_LOCAL(pptSrc); + xfree(pptSrc); } } REGION_UNINIT(pGC->pScreen, &rgnDst); diff --git a/mfb/mfbwindow.c b/mfb/mfbwindow.c index 4cbf59fdc..30b8857b1 100644 --- a/mfb/mfbwindow.c +++ b/mfb/mfbwindow.c @@ -150,7 +150,7 @@ mfbCopyWindow(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; @@ -162,6 +162,6 @@ mfbCopyWindow(pWin, ptOldOrg, prgnSrc) mfbDoBitblt((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, GXcopy, prgnDst, pptSrc); - DEALLOCATE_LOCAL(pptSrc); + xfree(pptSrc); REGION_DESTROY(pWin->drawable.pScreen, prgnDst); }