summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2007-11-05 14:12:59 +0000
committerDaniel Stone <daniel@fooishbar.org>2007-11-05 14:34:43 +0000
commit914922fd6100a409a3dfd1c64511ed6bdc344bef (patch)
tree9d073014ac8bc779832aa98619ca54536927fa05
parent3b77689266e729411229ec83d2a90578ebc1d82f (diff)
DIX: Remove usage of alloca
Replace with heap allocations.
-rw-r--r--dix/colormap.c40
-rw-r--r--dix/devices.c4
-rw-r--r--dix/dixfonts.c8
-rw-r--r--dix/extension.c4
-rw-r--r--dix/grabs.c24
-rw-r--r--dix/property.c16
-rw-r--r--dix/resource.c6
-rw-r--r--dix/swaprep.c12
8 files changed, 57 insertions, 57 deletions
diff --git a/dix/colormap.c b/dix/colormap.c
index 73b666971..b27b8bc67 100644
--- a/dix/colormap.c
+++ b/dix/colormap.c
@@ -751,7 +751,7 @@ UpdateColors (ColormapPtr pmap)
pVisual = pmap->pVisual;
size = pVisual->ColormapEntries;
- defs = (xColorItem *)ALLOCATE_LOCAL(size * sizeof(xColorItem));
+ defs = (xColorItem *)xalloc(size * sizeof(xColorItem));
if (!defs)
return;
n = 0;
@@ -801,7 +801,7 @@ UpdateColors (ColormapPtr pmap)
}
if (n)
(*pmap->pScreen->StoreColors)(pmap, n, defs);
- DEALLOCATE_LOCAL(defs);
+ xfree(defs);
}
/* Get a read-only color from a ColorMap (probably slow for large maps)
@@ -1752,14 +1752,14 @@ AllocDirect (int client, ColormapPtr pmap, int c, int r, int g, int b, Bool cont
for(p = pixels; p < pixels + c; p++)
*p = 0;
- ppixRed = (Pixel *)ALLOCATE_LOCAL(npixR * sizeof(Pixel));
- ppixGreen = (Pixel *)ALLOCATE_LOCAL(npixG * sizeof(Pixel));
- ppixBlue = (Pixel *)ALLOCATE_LOCAL(npixB * sizeof(Pixel));
+ ppixRed = (Pixel *)xalloc(npixR * sizeof(Pixel));
+ ppixGreen = (Pixel *)xalloc(npixG * sizeof(Pixel));
+ ppixBlue = (Pixel *)xalloc(npixB * sizeof(Pixel));
if (!ppixRed || !ppixGreen || !ppixBlue)
{
- if (ppixBlue) DEALLOCATE_LOCAL(ppixBlue);
- if (ppixGreen) DEALLOCATE_LOCAL(ppixGreen);
- if (ppixRed) DEALLOCATE_LOCAL(ppixRed);
+ if (ppixBlue) xfree(ppixBlue);
+ if (ppixGreen) xfree(ppixGreen);
+ if (ppixRed) xfree(ppixRed);
return(BadAlloc);
}
@@ -1797,9 +1797,9 @@ AllocDirect (int client, ColormapPtr pmap, int c, int r, int g, int b, Bool cont
if (okB)
for(ppix = ppixBlue, npix = npixB; --npix >= 0; ppix++)
pmap->blue[*ppix].refcnt = 0;
- DEALLOCATE_LOCAL(ppixBlue);
- DEALLOCATE_LOCAL(ppixGreen);
- DEALLOCATE_LOCAL(ppixRed);
+ xfree(ppixBlue);
+ xfree(ppixGreen);
+ xfree(ppixRed);
return(BadAlloc);
}
@@ -1841,9 +1841,9 @@ AllocDirect (int client, ColormapPtr pmap, int c, int r, int g, int b, Bool cont
for (pDst = pixels; pDst < pixels + c; pDst++)
*pDst |= ALPHAMASK(pmap->pVisual);
- DEALLOCATE_LOCAL(ppixBlue);
- DEALLOCATE_LOCAL(ppixGreen);
- DEALLOCATE_LOCAL(ppixRed);
+ xfree(ppixBlue);
+ xfree(ppixGreen);
+ xfree(ppixRed);
return (Success);
}
@@ -1859,7 +1859,7 @@ AllocPseudo (int client, ColormapPtr pmap, int c, int r, Bool contig,
npix = c << r;
if ((r >= 32) || (npix > pmap->freeRed) || (npix < c))
return(BadAlloc);
- if(!(ppixTemp = (Pixel *)ALLOCATE_LOCAL(npix * sizeof(Pixel))))
+ if(!(ppixTemp = (Pixel *)xalloc(npix * sizeof(Pixel))))
return(BadAlloc);
ok = AllocCP(pmap, pmap->red, c, r, contig, ppixTemp, pmask);
@@ -1889,7 +1889,7 @@ AllocPseudo (int client, ColormapPtr pmap, int c, int r, Bool contig,
pmap->numPixelsRed[client] += npix;
pmap->freeRed -= npix;
}
- DEALLOCATE_LOCAL(ppixTemp);
+ xfree(ppixTemp);
return (ok ? Success : BadAlloc);
}
@@ -2089,7 +2089,7 @@ AllocShared (ColormapPtr pmap, Pixel *ppix, int c, int r, int g, int b,
npixClientNew = c << (r + g + b);
npixShared = (c << r) + (c << g) + (c << b);
- psharedList = (SHAREDCOLOR **)ALLOCATE_LOCAL(npixShared *
+ psharedList = (SHAREDCOLOR **)xalloc(npixShared *
sizeof(SHAREDCOLOR *));
if (!psharedList)
return FALSE;
@@ -2204,7 +2204,7 @@ AllocShared (ColormapPtr pmap, Pixel *ppix, int c, int r, int g, int b,
}
}
}
- DEALLOCATE_LOCAL(psharedList);
+ xfree(psharedList);
return TRUE;
}
@@ -2679,7 +2679,7 @@ IsMapInstalled(Colormap map, WindowPtr pWin)
Colormap *pmaps;
int imap, nummaps, found;
- pmaps = (Colormap *) ALLOCATE_LOCAL(
+ pmaps = (Colormap *) xalloc(
pWin->drawable.pScreen->maxInstalledCmaps * sizeof(Colormap));
if(!pmaps)
return(FALSE);
@@ -2694,6 +2694,6 @@ IsMapInstalled(Colormap map, WindowPtr pWin)
break;
}
}
- DEALLOCATE_LOCAL(pmaps);
+ xfree(pmaps);
return (found);
}
diff --git a/dix/devices.c b/dix/devices.c
index e05444eff..9798b97a6 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1997,7 +1997,7 @@ ProcGetMotionEvents(ClientPtr client)
{
if (CompareTimeStamps(stop, currentTime) == LATER)
stop = currentTime;
- coords = (xTimecoord *)ALLOCATE_LOCAL(mouse->valuator->numMotionEvents
+ coords = (xTimecoord *)xalloc(mouse->valuator->numMotionEvents
* sizeof(xTimecoord));
if (!coords)
return BadAlloc;
@@ -2031,7 +2031,7 @@ ProcGetMotionEvents(ClientPtr client)
(char *)coords);
}
if (coords)
- DEALLOCATE_LOCAL(coords);
+ xfree(coords);
return Success;
}
diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index c21b3ecb3..f214ef5ad 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -777,7 +777,7 @@ finish:
reply.nFonts = nnames;
reply.sequenceNumber = client->sequence;
- bufptr = bufferStart = (char *) ALLOCATE_LOCAL(reply.length << 2);
+ bufptr = bufferStart = (char *) xalloc(reply.length << 2);
if (!bufptr && reply.length) {
SendErrorToClient(client, X_ListFonts, 0, 0, BadAlloc);
@@ -802,7 +802,7 @@ finish:
client->pSwapReplyFunc = ReplySwapVector[X_ListFonts];
WriteSwappedDataToClient(client, sizeof(xListFontsReply), &reply);
(void) WriteToClient(client, stringLens + nnames, bufferStart);
- DEALLOCATE_LOCAL(bufferStart);
+ xfree(bufferStart);
bail:
if (c->slept)
@@ -1797,7 +1797,7 @@ SetDefaultFontPath(char *path)
/* get enough for string, plus values -- use up commas */
len = strlen(path) + 1;
- nump = cp = newpath = (unsigned char *) ALLOCATE_LOCAL(len);
+ nump = cp = newpath = (unsigned char *) xalloc(len);
if (!newpath)
return BadAlloc;
pp = (unsigned char *) path;
@@ -1818,7 +1818,7 @@ SetDefaultFontPath(char *path)
err = SetFontPathElements(num, newpath, &bad, TRUE);
- DEALLOCATE_LOCAL(newpath);
+ xfree(newpath);
return err;
}
diff --git a/dix/extension.c b/dix/extension.c
index 4c0c3d236..282d60ab7 100644
--- a/dix/extension.c
+++ b/dix/extension.c
@@ -364,7 +364,7 @@ ProcListExtensions(ClientPtr client)
total_length += strlen(extensions[i]->aliases[j]) + 1;
}
reply.length = (total_length + 3) >> 2;
- buffer = bufptr = (char *)ALLOCATE_LOCAL(total_length);
+ buffer = bufptr = (char *)xalloc(total_length);
if (!buffer)
return(BadAlloc);
for (i=0; i<NumExtensions; i++)
@@ -388,7 +388,7 @@ ProcListExtensions(ClientPtr client)
if (reply.length)
{
WriteToClient(client, total_length, buffer);
- DEALLOCATE_LOCAL(buffer);
+ xfree(buffer);
}
return(client->noClientException);
}
diff --git a/dix/grabs.c b/dix/grabs.c
index 2210cd05e..70d234857 100644
--- a/dix/grabs.c
+++ b/dix/grabs.c
@@ -369,16 +369,16 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab)
i++;
if (!i)
return TRUE;
- deletes = (GrabPtr *)ALLOCATE_LOCAL(i * sizeof(GrabPtr));
- adds = (GrabPtr *)ALLOCATE_LOCAL(i * sizeof(GrabPtr));
- updates = (Mask ***)ALLOCATE_LOCAL(i * sizeof(Mask **));
- details = (Mask **)ALLOCATE_LOCAL(i * sizeof(Mask *));
+ deletes = (GrabPtr *)xalloc(i * sizeof(GrabPtr));
+ adds = (GrabPtr *)xalloc(i * sizeof(GrabPtr));
+ updates = (Mask ***)xalloc(i * sizeof(Mask **));
+ details = (Mask **)xalloc(i * sizeof(Mask *));
if (!deletes || !adds || !updates || !details)
{
- if (details) DEALLOCATE_LOCAL(details);
- if (updates) DEALLOCATE_LOCAL(updates);
- if (adds) DEALLOCATE_LOCAL(adds);
- if (deletes) DEALLOCATE_LOCAL(deletes);
+ if (details) xfree(details);
+ if (updates) xfree(updates);
+ if (adds) xfree(adds);
+ if (deletes) xfree(deletes);
return FALSE;
}
ndels = nadds = nups = 0;
@@ -473,10 +473,10 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab)
*updates[i] = details[i];
}
}
- DEALLOCATE_LOCAL(details);
- DEALLOCATE_LOCAL(updates);
- DEALLOCATE_LOCAL(adds);
- DEALLOCATE_LOCAL(deletes);
+ xfree(details);
+ xfree(updates);
+ xfree(adds);
+ xfree(deletes);
return ok;
#undef UPDATE
diff --git a/dix/property.c b/dix/property.c
index e281dd765..994d3a7a5 100644
--- a/dix/property.c
+++ b/dix/property.c
@@ -122,7 +122,7 @@ ProcRotateProperties(ClientPtr client)
if (!stuff->nAtoms)
return(Success);
atoms = (Atom *) & stuff[1];
- props = (PropertyPtr *)ALLOCATE_LOCAL(stuff->nAtoms * sizeof(PropertyPtr));
+ props = (PropertyPtr *)xalloc(stuff->nAtoms * sizeof(PropertyPtr));
if (!props)
return(BadAlloc);
for (i = 0; i < stuff->nAtoms; i++)
@@ -131,19 +131,19 @@ ProcRotateProperties(ClientPtr client)
DixReadAccess|DixWriteAccess);
if (!ValidAtom(atoms[i]) || (XaceErrorOperation == action)) {
- DEALLOCATE_LOCAL(props);
+ xfree(props);
client->errorValue = atoms[i];
return BadAtom;
}
if (XaceIgnoreOperation == action) {
- DEALLOCATE_LOCAL(props);
+ xfree(props);
return Success;
}
for (j = i + 1; j < stuff->nAtoms; j++)
if (atoms[j] == atoms[i])
{
- DEALLOCATE_LOCAL(props);
+ xfree(props);
return BadMatch;
}
pProp = wUserProps (pWin);
@@ -153,7 +153,7 @@ ProcRotateProperties(ClientPtr client)
goto found;
pProp = pProp->next;
}
- DEALLOCATE_LOCAL(props);
+ xfree(props);
return BadMatch;
found:
props[i] = pProp;
@@ -175,7 +175,7 @@ found:
props[i]->propertyName = atoms[(i + delta) % stuff->nAtoms];
}
}
- DEALLOCATE_LOCAL(props);
+ xfree(props);
return Success;
}
@@ -575,7 +575,7 @@ ProcListProperties(ClientPtr client)
numProps++;
}
if (numProps)
- if(!(pAtoms = (Atom *)ALLOCATE_LOCAL(numProps * sizeof(Atom))))
+ if(!(pAtoms = (Atom *)xalloc(numProps * sizeof(Atom))))
return(BadAlloc);
xlpr.type = X_Reply;
@@ -594,7 +594,7 @@ ProcListProperties(ClientPtr client)
{
client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write;
WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms);
- DEALLOCATE_LOCAL(pAtoms);
+ xfree(pAtoms);
}
return(client->noClientException);
}
diff --git a/dix/resource.c b/dix/resource.c
index e83c529d3..c8297fb67 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -507,13 +507,13 @@ RebuildTable(int client)
*/
j = 2 * clientTable[client].buckets;
- tails = (ResourcePtr **)ALLOCATE_LOCAL(j * sizeof(ResourcePtr *));
+ tails = (ResourcePtr **)xalloc(j * sizeof(ResourcePtr *));
if (!tails)
return;
resources = (ResourcePtr *)xalloc(j * sizeof(ResourcePtr));
if (!resources)
{
- DEALLOCATE_LOCAL(tails);
+ xfree(tails);
return;
}
for (rptr = resources, tptr = tails; --j >= 0; rptr++, tptr++)
@@ -536,7 +536,7 @@ RebuildTable(int client)
*tptr = &res->next;
}
}
- DEALLOCATE_LOCAL(tails);
+ xfree(tails);
clientTable[client].buckets *= 2;
xfree(clientTable[client].resources);
clientTable[client].resources = resources;
diff --git a/dix/swaprep.c b/dix/swaprep.c
index 7d3251ae3..91469e17b 100644
--- a/dix/swaprep.c
+++ b/dix/swaprep.c
@@ -101,7 +101,7 @@ CopySwap32Write(ClientPtr pClient, int size, CARD32 *pbuf)
CARD32 tmpbuf[1];
/* Allocate as big a buffer as we can... */
- while (!(pbufT = (CARD32 *) ALLOCATE_LOCAL(bufsize)))
+ while (!(pbufT = (CARD32 *) xalloc(bufsize)))
{
bufsize >>= 1;
if (bufsize == 4)
@@ -133,7 +133,7 @@ CopySwap32Write(ClientPtr pClient, int size, CARD32 *pbuf)
}
if (pbufT != tmpbuf)
- DEALLOCATE_LOCAL ((char *) pbufT);
+ xfree ((char *) pbufT);
}
/**
@@ -149,7 +149,7 @@ CopySwap16Write(ClientPtr pClient, int size, short *pbuf)
short tmpbuf[2];
/* Allocate as big a buffer as we can... */
- while (!(pbufT = (short *) ALLOCATE_LOCAL(bufsize)))
+ while (!(pbufT = (short *) xalloc(bufsize)))
{
bufsize >>= 1;
if (bufsize == 4)
@@ -181,7 +181,7 @@ CopySwap16Write(ClientPtr pClient, int size, short *pbuf)
}
if (pbufT != tmpbuf)
- DEALLOCATE_LOCAL ((char *) pbufT);
+ xfree ((char *) pbufT);
}
@@ -1267,7 +1267,7 @@ WriteSConnectionInfo(ClientPtr pClient, unsigned long size, char *pInfo)
{
char *pInfoTBase;
- pInfoTBase = (char *) ALLOCATE_LOCAL(size);
+ pInfoTBase = (char *) xalloc(size);
if (!pInfoTBase)
{
pClient->noClientException = -1;
@@ -1275,7 +1275,7 @@ WriteSConnectionInfo(ClientPtr pClient, unsigned long size, char *pInfo)
}
SwapConnSetupInfo(pInfo, pInfoTBase);
(void)WriteToClient(pClient, (int)size, (char *) pInfoTBase);
- DEALLOCATE_LOCAL(pInfoTBase);
+ xfree(pInfoTBase);
}
_X_EXPORT void