diff options
author | Daniel Stone <daniel@fooishbar.org> | 2007-11-05 14:18:22 +0000 |
---|---|---|
committer | Daniel Stone <daniel@fooishbar.org> | 2007-11-05 14:34:46 +0000 |
commit | 934281126f6c602fa4bd0c2e29d8c9f44fe532b8 (patch) | |
tree | 90ae5f5a9d43a266d8ba361764370e6874f079c7 | |
parent | fb32bb9839b615f7297fbfac2050bc216682f01c (diff) |
Xext: Remove usage of alloca
Replace with heap allocations.
-rw-r--r-- | Xext/mbuf.c | 40 | ||||
-rw-r--r-- | Xext/mbufbf.c | 4 | ||||
-rw-r--r-- | Xext/mbufpx.c | 4 | ||||
-rw-r--r-- | Xext/panoramiXprocs.c | 32 | ||||
-rw-r--r-- | Xext/saver.c | 4 | ||||
-rw-r--r-- | Xext/shape.c | 6 | ||||
-rw-r--r-- | Xext/sync.c | 12 | ||||
-rw-r--r-- | Xext/xace.c | 4 | ||||
-rw-r--r-- | Xext/xf86bigfont.c | 18 | ||||
-rw-r--r-- | Xext/xres.c | 8 |
10 files changed, 66 insertions, 66 deletions
diff --git a/Xext/mbuf.c b/Xext/mbuf.c index f9ff0858c..729656048 100644 --- a/Xext/mbuf.c +++ b/Xext/mbuf.c @@ -524,12 +524,12 @@ ProcDisplayImageBuffers (client) return Success; minDelay = stuff->minDelay; ids = (XID *) &stuff[1]; - ppMultibuffers = (MultibuffersPtr *) ALLOCATE_LOCAL(nbuf * sizeof (MultibuffersPtr)); - pMultibuffer = (MultibufferPtr *) ALLOCATE_LOCAL(nbuf * sizeof (MultibufferPtr)); + ppMultibuffers = (MultibuffersPtr *) xalloc(nbuf * sizeof (MultibuffersPtr)); + pMultibuffer = (MultibufferPtr *) xalloc(nbuf * sizeof (MultibufferPtr)); if (!ppMultibuffers || !pMultibuffer) { - if (ppMultibuffers) DEALLOCATE_LOCAL(ppMultibuffers); - if (pMultibuffer) DEALLOCATE_LOCAL(pMultibuffer); + if (ppMultibuffers) xfree(ppMultibuffers); + if (pMultibuffer) xfree(pMultibuffer); client->errorValue = 0; return BadAlloc; } @@ -541,8 +541,8 @@ ProcDisplayImageBuffers (client) MultibufferResType); if (!pMultibuffer[i]) { - DEALLOCATE_LOCAL(ppMultibuffers); - DEALLOCATE_LOCAL(pMultibuffer); + xfree(ppMultibuffers); + xfree(pMultibuffer); client->errorValue = ids[i]; return MultibufferErrorBase + MultibufferBadBuffer; } @@ -551,8 +551,8 @@ MultibufferResType); { if (ppMultibuffers[i] == ppMultibuffers[j]) { - DEALLOCATE_LOCAL(ppMultibuffers); - DEALLOCATE_LOCAL(pMultibuffer); + xfree(ppMultibuffers); + xfree(pMultibuffer); client->errorValue = ids[i]; return BadMatch; } @@ -571,8 +571,8 @@ MultibufferResType); else PerformDisplayRequest (ppMultibuffers, pMultibuffer, nbuf); - DEALLOCATE_LOCAL(ppMultibuffers); - DEALLOCATE_LOCAL(pMultibuffer); + xfree(ppMultibuffers); + xfree(pMultibuffer); return Success; } @@ -665,7 +665,7 @@ ProcGetMBufferAttributes (client) pMultibuffers = (MultibuffersPtr)LookupIDByType (pWin->drawable.id, MultibuffersResType); if (!pMultibuffers) return BadAccess; - ids = (XID *) ALLOCATE_LOCAL (pMultibuffers->numMultibuffer * sizeof (XID)); + ids = (XID *) xalloc (pMultibuffers->numMultibuffer * sizeof (XID)); if (!ids) return BadAlloc; for (i = 0; i < pMultibuffers->numMultibuffer; i++) @@ -688,7 +688,7 @@ ProcGetMBufferAttributes (client) (char *)&rep); WriteToClient (client, (int)(pMultibuffers->numMultibuffer * sizeof (XID)), (char *)ids); - DEALLOCATE_LOCAL((pointer) ids); + xfree((pointer) ids); return client->noClientException; } @@ -803,7 +803,7 @@ ProcGetBufferInfo (client) nInfo += pDepth->numVids; } pInfo = (xMbufBufferInfo *) - ALLOCATE_LOCAL (nInfo * sizeof (xMbufBufferInfo)); + xalloc (nInfo * sizeof (xMbufBufferInfo)); if (!pInfo) return BadAlloc; @@ -839,7 +839,7 @@ ProcGetBufferInfo (client) } WriteToClient (client, sizeof (xMbufGetBufferInfoReply), (pointer) &rep); WriteToClient (client, (int) nInfo * sizeof (xMbufBufferInfo), (pointer) pInfo); - DEALLOCATE_LOCAL ((pointer) pInfo); + xfree ((pointer) pInfo); return client->noClientException; } @@ -1256,7 +1256,7 @@ DisplayImageBuffers (ids, nbuf) MultibuffersPtr *pMultibuffers; int i, j; - pMultibuffer = (MultibufferPtr *) ALLOCATE_LOCAL (nbuf * sizeof *pMultibuffer + + pMultibuffer = (MultibufferPtr *) xalloc (nbuf * sizeof *pMultibuffer + nbuf * sizeof *pMultibuffers); if (!pMultibuffer) return BadAlloc; @@ -1266,19 +1266,19 @@ DisplayImageBuffers (ids, nbuf) pMultibuffer[i] = (MultibufferPtr) LookupIDByType (ids[i], MultibufferResType); if (!pMultibuffer[i]) { - DEALLOCATE_LOCAL (pMultibuffer); + xfree (pMultibuffer); return MultibufferErrorBase + MultibufferBadBuffer; } pMultibuffers[i] = pMultibuffer[i]->pMultibuffers; for (j = 0; j < i; j++) if (pMultibuffers[i] == pMultibuffers[j]) { - DEALLOCATE_LOCAL (pMultibuffer); + xfree (pMultibuffer); return BadMatch; } } PerformDisplayRequest (pMultibuffers, pMultibuffer, nbuf); - DEALLOCATE_LOCAL (pMultibuffer); + xfree (pMultibuffer); return Success; } @@ -1382,7 +1382,7 @@ MultibufferExpose (pMultibuffer, pRegion) numRects = REGION_NUM_RECTS(pRegion); pBox = REGION_RECTS(pRegion); - pEvent = (xEvent *) ALLOCATE_LOCAL(numRects * sizeof(xEvent)); + pEvent = (xEvent *) xalloc(numRects * sizeof(xEvent)); if (pEvent) { pe = pEvent; @@ -1398,7 +1398,7 @@ MultibufferExpose (pMultibuffer, pRegion) } (void) DeliverEventsToMultibuffer (pMultibuffer, pEvent, numRects, ExposureMask); - DEALLOCATE_LOCAL(pEvent); + xfree(pEvent); } } } diff --git a/Xext/mbufbf.c b/Xext/mbufbf.c index b879abcb0..a3b3de79d 100644 --- a/Xext/mbufbf.c +++ b/Xext/mbufbf.c @@ -614,7 +614,7 @@ bufDrawSelectPlane(pScreen, selectPlane, prgn, bufferNum) if (!pGC) return; - prect = (xRectangle *)ALLOCATE_LOCAL(REGION_NUM_RECTS(prgn) * + prect = (xRectangle *)xalloc(REGION_NUM_RECTS(prgn) * sizeof(xRectangle)); if (!prect) { @@ -638,7 +638,7 @@ bufDrawSelectPlane(pScreen, selectPlane, prgn, bufferNum) prect -= numRects; (* pGC->ops->PolyFillRect)(pDrawable, pGC, numRects, prect); - DEALLOCATE_LOCAL(prect); + xfree(prect); FreeScratchGC (pGC); } diff --git a/Xext/mbufpx.c b/Xext/mbufpx.c index a04b97d9d..21d525906 100644 --- a/Xext/mbufpx.c +++ b/Xext/mbufpx.c @@ -263,7 +263,7 @@ MultibufferPaintBackgroundRegion(pWin, pDrawable, pRegion) int nrects = REGION_NUM_RECTS(pRegion); BoxPtr pbox = REGION_RECTS(pRegion); - pRects = (xRectangle *)ALLOCATE_LOCAL(nrects * sizeof(xRectangle)); + pRects = (xRectangle *)xalloc(nrects * sizeof(xRectangle)); if (pRects) { int i; @@ -275,7 +275,7 @@ MultibufferPaintBackgroundRegion(pWin, pDrawable, pRegion) pRects[i].height = pbox->y2 - pbox->y1; } MultibufferPaintBackgroundRectangles(pWin, pDrawable, nrects, pRects); - DEALLOCATE_LOCAL(pRects); + xfree(pRects); } } diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c index 1c53a1e1a..f51f65663 100644 --- a/Xext/panoramiXprocs.c +++ b/Xext/panoramiXprocs.c @@ -1272,7 +1272,7 @@ int PanoramiXPolyPoint(ClientPtr client) isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; npoint = ((client->req_len << 2) - sizeof(xPolyPointReq)) >> 2; if (npoint > 0) { - origPts = (xPoint *) ALLOCATE_LOCAL(npoint * sizeof(xPoint)); + origPts = (xPoint *) xalloc(npoint * sizeof(xPoint)); memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint)); FOR_NSCREENS_FORWARD(j){ @@ -1299,7 +1299,7 @@ int PanoramiXPolyPoint(ClientPtr client) result = (* SavedProcVector[X_PolyPoint])(client); if(result != Success) break; } - DEALLOCATE_LOCAL(origPts); + xfree(origPts); return (result); } else return (client->noClientException); @@ -1330,7 +1330,7 @@ int PanoramiXPolyLine(ClientPtr client) isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; npoint = ((client->req_len << 2) - sizeof(xPolyLineReq)) >> 2; if (npoint > 0){ - origPts = (xPoint *) ALLOCATE_LOCAL(npoint * sizeof(xPoint)); + origPts = (xPoint *) xalloc(npoint * sizeof(xPoint)); memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint)); FOR_NSCREENS_FORWARD(j){ @@ -1357,7 +1357,7 @@ int PanoramiXPolyLine(ClientPtr client) result = (* SavedProcVector[X_PolyLine])(client); if(result != Success) break; } - DEALLOCATE_LOCAL(origPts); + xfree(origPts); return (result); } else return (client->noClientException); @@ -1391,7 +1391,7 @@ int PanoramiXPolySegment(ClientPtr client) if(nsegs & 4) return BadLength; nsegs >>= 3; if (nsegs > 0) { - origSegs = (xSegment *) ALLOCATE_LOCAL(nsegs * sizeof(xSegment)); + origSegs = (xSegment *) xalloc(nsegs * sizeof(xSegment)); memcpy((char *) origSegs, (char *) &stuff[1], nsegs * sizeof(xSegment)); FOR_NSCREENS_FORWARD(j){ @@ -1418,7 +1418,7 @@ int PanoramiXPolySegment(ClientPtr client) result = (* SavedProcVector[X_PolySegment])(client); if(result != Success) break; } - DEALLOCATE_LOCAL(origSegs); + xfree(origSegs); return (result); } else return (client->noClientException); @@ -1453,7 +1453,7 @@ int PanoramiXPolyRectangle(ClientPtr client) if(nrects & 4) return BadLength; nrects >>= 3; if (nrects > 0){ - origRecs = (xRectangle *) ALLOCATE_LOCAL(nrects * sizeof(xRectangle)); + origRecs = (xRectangle *) xalloc(nrects * sizeof(xRectangle)); memcpy((char *)origRecs,(char *)&stuff[1],nrects * sizeof(xRectangle)); FOR_NSCREENS_FORWARD(j){ @@ -1479,7 +1479,7 @@ int PanoramiXPolyRectangle(ClientPtr client) result = (* SavedProcVector[X_PolyRectangle])(client); if(result != Success) break; } - DEALLOCATE_LOCAL(origRecs); + xfree(origRecs); return (result); } else return (client->noClientException); @@ -1513,7 +1513,7 @@ int PanoramiXPolyArc(ClientPtr client) if(narcs % sizeof(xArc)) return BadLength; narcs /= sizeof(xArc); if (narcs > 0){ - origArcs = (xArc *) ALLOCATE_LOCAL(narcs * sizeof(xArc)); + origArcs = (xArc *) xalloc(narcs * sizeof(xArc)); memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc)); FOR_NSCREENS_FORWARD(j){ @@ -1537,7 +1537,7 @@ int PanoramiXPolyArc(ClientPtr client) result = (* SavedProcVector[X_PolyArc])(client); if(result != Success) break; } - DEALLOCATE_LOCAL(origArcs); + xfree(origArcs); return (result); } else return (client->noClientException); @@ -1569,7 +1569,7 @@ int PanoramiXFillPoly(ClientPtr client) count = ((client->req_len << 2) - sizeof(xFillPolyReq)) >> 2; if (count > 0){ - locPts = (DDXPointPtr) ALLOCATE_LOCAL(count * sizeof(DDXPointRec)); + locPts = (DDXPointPtr) xalloc(count * sizeof(DDXPointRec)); memcpy((char *)locPts, (char *)&stuff[1], count * sizeof(DDXPointRec)); FOR_NSCREENS_FORWARD(j){ @@ -1596,7 +1596,7 @@ int PanoramiXFillPoly(ClientPtr client) result = (* SavedProcVector[X_FillPoly])(client); if(result != Success) break; } - DEALLOCATE_LOCAL(locPts); + xfree(locPts); return (result); } else return (client->noClientException); @@ -1630,7 +1630,7 @@ int PanoramiXPolyFillRectangle(ClientPtr client) if(things & 4) return BadLength; things >>= 3; if (things > 0){ - origRects = (xRectangle *) ALLOCATE_LOCAL(things * sizeof(xRectangle)); + origRects = (xRectangle *) xalloc(things * sizeof(xRectangle)); memcpy((char*)origRects,(char*)&stuff[1], things * sizeof(xRectangle)); FOR_NSCREENS_FORWARD(j){ @@ -1655,7 +1655,7 @@ int PanoramiXPolyFillRectangle(ClientPtr client) result = (* SavedProcVector[X_PolyFillRectangle])(client); if(result != Success) break; } - DEALLOCATE_LOCAL(origRects); + xfree(origRects); return (result); } else return (client->noClientException); @@ -1689,7 +1689,7 @@ int PanoramiXPolyFillArc(ClientPtr client) IF_RETURN((narcs % sizeof(xArc)), BadLength); narcs /= sizeof(xArc); if (narcs > 0) { - origArcs = (xArc *) ALLOCATE_LOCAL(narcs * sizeof(xArc)); + origArcs = (xArc *) xalloc(narcs * sizeof(xArc)); memcpy((char *) origArcs, (char *)&stuff[1], narcs * sizeof(xArc)); FOR_NSCREENS_FORWARD(j){ @@ -1714,7 +1714,7 @@ int PanoramiXPolyFillArc(ClientPtr client) result = (* SavedProcVector[X_PolyFillArc])(client); if(result != Success) break; } - DEALLOCATE_LOCAL(origArcs); + xfree(origArcs); return (result); } else return (client->noClientException); diff --git a/Xext/saver.c b/Xext/saver.c index a9f1dd36c..a590583df 100644 --- a/Xext/saver.c +++ b/Xext/saver.c @@ -673,7 +673,7 @@ CreateSaverWindow (pScreen) wantMap = wColormap (pWin); if (wantMap == None) return TRUE; - installedMaps = (Colormap *) ALLOCATE_LOCAL (pScreen->maxInstalledCmaps * + installedMaps = (Colormap *) xalloc (pScreen->maxInstalledCmaps * sizeof (Colormap)); numInstalled = (*pWin->drawable.pScreen->ListInstalledColormaps) (pScreen, installedMaps); @@ -681,7 +681,7 @@ CreateSaverWindow (pScreen) if (installedMaps[i] == wantMap) break; - DEALLOCATE_LOCAL ((char *) installedMaps); + xfree ((char *) installedMaps); if (i < numInstalled) return TRUE; diff --git a/Xext/shape.c b/Xext/shape.c index 928eeee31..6515a10d7 100644 --- a/Xext/shape.c +++ b/Xext/shape.c @@ -1060,7 +1060,7 @@ ProcShapeGetRectangles (client) } if (!region) { nrects = 1; - rects = (xRectangle *) ALLOCATE_LOCAL (sizeof (xRectangle)); + rects = (xRectangle *) xalloc (sizeof (xRectangle)); if (!rects) return BadAlloc; switch (stuff->kind) { @@ -1087,7 +1087,7 @@ ProcShapeGetRectangles (client) BoxPtr box; nrects = REGION_NUM_RECTS(region); box = REGION_RECTS(region); - rects = (xRectangle *) ALLOCATE_LOCAL (nrects * sizeof (xRectangle)); + rects = (xRectangle *) xalloc (nrects * sizeof (xRectangle)); if (!rects && nrects) return BadAlloc; for (i = 0; i < nrects; i++, box++) { @@ -1110,7 +1110,7 @@ ProcShapeGetRectangles (client) } WriteToClient (client, sizeof (rep), (char *) &rep); WriteToClient (client, nrects * sizeof (xRectangle), (char *) rects); - DEALLOCATE_LOCAL (rects); + xfree (rects); return client->noClientException; } diff --git a/Xext/sync.c b/Xext/sync.c index d9b6a9f06..e87e0bd24 100644 --- a/Xext/sync.c +++ b/Xext/sync.c @@ -601,7 +601,7 @@ SyncSendCounterNotifyEvents(client, ppAwait, num_events) if (client->clientGone) return; pev = pEvents = (xSyncCounterNotifyEvent *) - ALLOCATE_LOCAL(num_events * sizeof(xSyncCounterNotifyEvent)); + xalloc(num_events * sizeof(xSyncCounterNotifyEvent)); if (!pEvents) return; UpdateCurrentTime(); @@ -622,7 +622,7 @@ SyncSendCounterNotifyEvents(client, ppAwait, num_events) } /* swapping will be taken care of by this */ WriteEventsToClient(client, num_events, (xEvent *)pEvents); - DEALLOCATE_LOCAL(pEvents); + xfree(pEvents); } @@ -732,7 +732,7 @@ SyncAwaitTriggerFired(pTrigger) pAwaitUnion = (SyncAwaitUnion *)pAwait->pHeader; numwaits = pAwaitUnion->header.num_waitconditions; - ppAwait = (SyncAwait **)ALLOCATE_LOCAL(numwaits * sizeof(SyncAwait *)); + ppAwait = (SyncAwait **)xalloc(numwaits * sizeof(SyncAwait *)); if (!ppAwait) goto bail; @@ -801,7 +801,7 @@ SyncAwaitTriggerFired(pTrigger) if (num_events) SyncSendCounterNotifyEvents(pAwaitUnion->header.client, ppAwait, num_events); - DEALLOCATE_LOCAL(ppAwait); + xfree(ppAwait); bail: /* unblock the client */ @@ -1396,7 +1396,7 @@ ProcSyncListSystemCounters(client) if (len) { - walklist = list = (xSyncSystemCounter *) ALLOCATE_LOCAL(len); + walklist = list = (xSyncSystemCounter *) xalloc(len); if (!list) return BadAlloc; } @@ -1442,7 +1442,7 @@ ProcSyncListSystemCounters(client) if (len) { WriteToClient(client, len, (char *) list); - DEALLOCATE_LOCAL(list); + xfree(list); } return (client->noClientException); diff --git a/Xext/xace.c b/Xext/xace.c index 63856315c..00c3b8f9b 100644 --- a/Xext/xace.c +++ b/Xext/xace.c @@ -437,7 +437,7 @@ XaceCensorImage(client, pVisibleRegion, widthBytesLine, pDraw, x, y, w, h, /* convert region to list-of-rectangles for PolyFillRect */ - pRects = (xRectangle *)ALLOCATE_LOCAL(nRects * sizeof(xRectangle *)); + pRects = (xRectangle *)xalloc(nRects * sizeof(xRectangle *)); if (!pRects) { failed = TRUE; @@ -489,7 +489,7 @@ XaceCensorImage(client, pVisibleRegion, widthBytesLine, pDraw, x, y, w, h, */ bzero(pBuf, (int)(widthBytesLine * h)); } - if (pRects) DEALLOCATE_LOCAL(pRects); + if (pRects) xfree(pRects); if (pScratchGC) FreeScratchGC(pScratchGC); if (pPix) FreeScratchPixmapHeader(pPix); } diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c index c2f891a7e..b20e82d6e 100644 --- a/Xext/xf86bigfont.c +++ b/Xext/xf86bigfont.c @@ -491,7 +491,7 @@ ProcXF86BigfontQueryFont( } else { #endif pCI = (xCharInfo *) - ALLOCATE_LOCAL(nCharInfos * sizeof(xCharInfo)); + xalloc(nCharInfos * sizeof(xCharInfo)); if (!pCI) return BadAlloc; #ifdef HAS_SHM @@ -554,9 +554,9 @@ ProcXF86BigfontQueryFont( hashModulus = nCharInfos+1; tmp = (CARD16*) - ALLOCATE_LOCAL((4*nCharInfos+1) * sizeof(CARD16)); + xalloc((4*nCharInfos+1) * sizeof(CARD16)); if (!tmp) { - if (!pDesc) DEALLOCATE_LOCAL(pCI); + if (!pDesc) xfree(pCI); return BadAlloc; } pIndex2UniqIndex = tmp; @@ -639,12 +639,12 @@ ProcXF86BigfontQueryFont( + (nCharInfos+1)/2 * 2 * sizeof(CARD16) : 0); xXF86BigfontQueryFontReply* reply = - (xXF86BigfontQueryFontReply *) ALLOCATE_LOCAL(rlength); + (xXF86BigfontQueryFontReply *) xalloc(rlength); char* p; if (!reply) { if (nCharInfos > 0) { - if (shmid == -1) DEALLOCATE_LOCAL(pIndex2UniqIndex); - if (!pDesc) DEALLOCATE_LOCAL(pCI); + if (shmid == -1) xfree(pIndex2UniqIndex); + if (!pDesc) xfree(pCI); } return BadAlloc; } @@ -722,10 +722,10 @@ ProcXF86BigfontQueryFont( } } WriteToClient(client, rlength, (char *)reply); - DEALLOCATE_LOCAL(reply); + xfree(reply); if (nCharInfos > 0) { - if (shmid == -1) DEALLOCATE_LOCAL(pIndex2UniqIndex); - if (!pDesc) DEALLOCATE_LOCAL(pCI); + if (shmid == -1) xfree(pIndex2UniqIndex); + if (!pDesc) xfree(pCI); } return (client->noClientException); } diff --git a/Xext/xres.c b/Xext/xres.c index 1617337bf..32cc9030d 100644 --- a/Xext/xres.c +++ b/Xext/xres.c @@ -63,7 +63,7 @@ ProcXResQueryClients (ClientPtr client) REQUEST_SIZE_MATCH(xXResQueryClientsReq); - current_clients = ALLOCATE_LOCAL((currentMaxClients - 1) * sizeof(int)); + current_clients = xalloc((currentMaxClients - 1) * sizeof(int)); num_clients = 0; for(i = 1; i < currentMaxClients; i++) { @@ -101,7 +101,7 @@ ProcXResQueryClients (ClientPtr client) } } - DEALLOCATE_LOCAL(current_clients); + xfree(current_clients); return (client->noClientException); } @@ -134,7 +134,7 @@ ProcXResQueryClientResources (ClientPtr client) return BadValue; } - counts = ALLOCATE_LOCAL((lastResourceType + 1) * sizeof(int)); + counts = xalloc((lastResourceType + 1) * sizeof(int)); memset(counts, 0, (lastResourceType + 1) * sizeof(int)); @@ -183,7 +183,7 @@ ProcXResQueryClientResources (ClientPtr client) } } - DEALLOCATE_LOCAL(counts); + xfree(counts); return (client->noClientException); } |