Commit 93428112 authored by Daniel Stone's avatar Daniel Stone

Xext: Remove usage of alloca

Replace with heap allocations.
parent fb32bb98
......@@ -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);
}
}
}
......
......@@ -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);
}
......
......@@ -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);
}
}
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment