Commit 3f3ff971 authored by Mikhail Gusarov's avatar Mikhail Gusarov

Replace X-allocation functions with their C89 counterparts

The only remaining X-functions used in server are XNF*, the rest is converted to
plain alloc/calloc/realloc/free/strdup.

X* functions are still exported from server and x* macros are still defined in
header file, so both ABI and API are not affected by this change.
Signed-off-by: Mikhail Gusarov's avatarMikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 96c7ab27
......@@ -158,7 +158,7 @@ XineramaCloseScreen (int i, ScreenPtr pScreen)
if (pScreen->myNum == 0)
REGION_UNINIT(pScreen, &PanoramiXScreenRegion);
xfree ((pointer) pScreenPriv);
free((pointer) pScreenPriv);
return (*pScreen->CloseScreen) (i, pScreen);
}
......@@ -328,7 +328,7 @@ XineramaDestroyClip(GCPtr pGC)
int
XineramaDeleteResource(pointer data, XID id)
{
xfree(data);
free(data);
return 1;
}
......@@ -376,7 +376,7 @@ XineramaRegisterConnectionBlockCallback(void (*func)(void))
{
XineramaConnectionCallbackList *newlist;
if(!(newlist = xalloc(sizeof(XineramaConnectionCallbackList))))
if(!(newlist = malloc(sizeof(XineramaConnectionCallbackList))))
return FALSE;
newlist->next = ConnectionCallbackList;
......@@ -474,7 +474,7 @@ void PanoramiXExtensionInit(int argc, char *argv[])
*/
panoramiXdataPtr = (PanoramiXData *)
xcalloc(PanoramiXNumScreens, sizeof(PanoramiXData));
calloc(PanoramiXNumScreens, sizeof(PanoramiXData));
if (!panoramiXdataPtr)
break;
......@@ -486,7 +486,7 @@ void PanoramiXExtensionInit(int argc, char *argv[])
for (i = 0; i < PanoramiXNumScreens; i++) {
pScreen = screenInfo.screens[i];
pScreenPriv = xalloc(sizeof(PanoramiXScreenRec));
pScreenPriv = malloc(sizeof(PanoramiXScreenRec));
dixSetPrivate(&pScreen->devPrivates, PanoramiXScreenKey,
pScreenPriv);
if(!pScreenPriv) {
......@@ -675,8 +675,8 @@ Bool PanoramiXCreateConnectionBlock(void)
connSetupPrefix.length = bytes_to_int32(length);
for (i = 0; i < PanoramiXNumDepths; i++)
xfree(PanoramiXDepths[i].vids);
xfree(PanoramiXDepths);
free(PanoramiXDepths[i].vids);
free(PanoramiXDepths);
PanoramiXDepths = NULL;
/*
......@@ -699,7 +699,7 @@ Bool PanoramiXCreateConnectionBlock(void)
tmp = (pointer)ConnectionCallbackList;
(*ConnectionCallbackList->func)();
ConnectionCallbackList = ConnectionCallbackList->next;
xfree(tmp);
free(tmp);
}
return TRUE;
......@@ -750,13 +750,13 @@ PanoramiXMaybeAddDepth(DepthPtr pDepth)
j = PanoramiXNumDepths;
PanoramiXNumDepths++;
PanoramiXDepths = xrealloc(PanoramiXDepths,
PanoramiXDepths = realloc(PanoramiXDepths,
PanoramiXNumDepths * sizeof(DepthRec));
PanoramiXDepths[j].depth = pDepth->depth;
PanoramiXDepths[j].numVids = 0;
/* XXX suboptimal, should grow these dynamically */
if(pDepth->numVids)
PanoramiXDepths[j].vids = xalloc(sizeof(VisualID) * pDepth->numVids);
PanoramiXDepths[j].vids = malloc(sizeof(VisualID) * pDepth->numVids);
else
PanoramiXDepths[j].vids = NULL;
}
......@@ -792,7 +792,7 @@ PanoramiXMaybeAddVisual(VisualPtr pVisual)
/* found a matching visual on all screens, add it to the subset list */
j = PanoramiXNumVisuals;
PanoramiXNumVisuals++;
PanoramiXVisuals = xrealloc(PanoramiXVisuals,
PanoramiXVisuals = realloc(PanoramiXVisuals,
PanoramiXNumVisuals * sizeof(VisualRec));
memcpy(&PanoramiXVisuals[j], pVisual, sizeof(VisualRec));
......@@ -824,11 +824,11 @@ PanoramiXConsolidate(void)
for (i = 0; i < pScreen->numVisuals; i++)
PanoramiXMaybeAddVisual(pVisual++);
root = xalloc(sizeof(PanoramiXRes));
root = malloc(sizeof(PanoramiXRes));
root->type = XRT_WINDOW;
defmap = xalloc(sizeof(PanoramiXRes));
defmap = malloc(sizeof(PanoramiXRes));
defmap->type = XRT_COLORMAP;
saver = xalloc(sizeof(PanoramiXRes));
saver = malloc(sizeof(PanoramiXRes));
saver->type = XRT_WINDOW;
for (i = 0; i < PanoramiXNumScreens; i++) {
......@@ -893,7 +893,7 @@ static void PanoramiXResetProc(ExtensionEntry* extEntry)
for (i = 256; i--; )
ProcVector[i] = SavedProcVector[i];
Xfree(panoramiXdataPtr);
free(panoramiXdataPtr);
}
......@@ -1202,7 +1202,7 @@ XineramaGetImageData(
if(sizeNeeded > size) {
char *tmpdata = ScratchMem;
ScratchMem = xrealloc(ScratchMem, sizeNeeded);
ScratchMem = realloc(ScratchMem, sizeNeeded);
if(ScratchMem)
size = sizeNeeded;
else {
......@@ -1277,7 +1277,7 @@ XineramaGetImageData(
}
if(ScratchMem)
xfree(ScratchMem);
free(ScratchMem);
REGION_UNINIT(pScreen, &SrcRegion);
REGION_UNINIT(pScreen, &GrabRegion);
......
......@@ -120,7 +120,7 @@ int PanoramiXCreateWindow(ClientPtr client)
}
}
if(!(newWin = xalloc(sizeof(PanoramiXRes))))
if(!(newWin = malloc(sizeof(PanoramiXRes))))
return BadAlloc;
newWin->type = XRT_WINDOW;
......@@ -160,7 +160,7 @@ int PanoramiXCreateWindow(ClientPtr client)
if (result == Success)
AddResource(newWin->info[0].id, XRT_WINDOW, newWin);
else
xfree(newWin);
free(newWin);
return (result);
}
......@@ -666,7 +666,7 @@ int PanoramiXCreatePixmap(ClientPtr client)
if (result != Success)
return (result == BadValue) ? BadDrawable : result;
if(!(newPix = xalloc(sizeof(PanoramiXRes))))
if(!(newPix = malloc(sizeof(PanoramiXRes))))
return BadAlloc;
newPix->type = XRT_PIXMAP;
......@@ -685,7 +685,7 @@ int PanoramiXCreatePixmap(ClientPtr client)
if (result == Success)
AddResource(newPix->info[0].id, XRT_PIXMAP, newPix);
else
xfree(newPix);
free(newPix);
return (result);
}
......@@ -771,7 +771,7 @@ int PanoramiXCreateGC(ClientPtr client)
}
}
if(!(newGC = xalloc(sizeof(PanoramiXRes))))
if(!(newGC = malloc(sizeof(PanoramiXRes))))
return BadAlloc;
newGC->type = XRT_GC;
......@@ -795,7 +795,7 @@ int PanoramiXCreateGC(ClientPtr client)
if (result == Success)
AddResource(newGC->info[0].id, XRT_GC, newGC);
else
xfree(newGC);
free(newGC);
return (result);
}
......@@ -1064,7 +1064,7 @@ int PanoramiXCopyArea(ClientPtr client)
}
pitch = PixmapBytePad(stuff->width, drawables[0]->depth);
if(!(data = xcalloc(1, stuff->height * pitch)))
if(!(data = calloc(1, stuff->height * pitch)))
return BadAlloc;
XineramaGetImageData(drawables, srcx, srcy,
......@@ -1076,7 +1076,7 @@ int PanoramiXCopyArea(ClientPtr client)
VALIDATE_DRAWABLE_AND_GC(dst->info[j].id, pDst, DixWriteAccess);
if(drawables[0]->depth != pDst->depth) {
client->errorValue = stuff->dstDrawable;
xfree(data);
free(data);
return (BadMatch);
}
......@@ -1087,7 +1087,7 @@ int PanoramiXCopyArea(ClientPtr client)
if(dstShared) break;
}
xfree(data);
free(data);
result = Success;
} else {
......@@ -1301,7 +1301,7 @@ int PanoramiXPolyPoint(ClientPtr client)
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq));
if (npoint > 0) {
origPts = xalloc(npoint * sizeof(xPoint));
origPts = malloc(npoint * sizeof(xPoint));
memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint));
FOR_NSCREENS_FORWARD(j){
......@@ -1328,7 +1328,7 @@ int PanoramiXPolyPoint(ClientPtr client)
result = (* SavedProcVector[X_PolyPoint])(client);
if(result != Success) break;
}
xfree(origPts);
free(origPts);
return (result);
} else
return (client->noClientException);
......@@ -1361,7 +1361,7 @@ int PanoramiXPolyLine(ClientPtr client)
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq));
if (npoint > 0){
origPts = xalloc(npoint * sizeof(xPoint));
origPts = malloc(npoint * sizeof(xPoint));
memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint));
FOR_NSCREENS_FORWARD(j){
......@@ -1388,7 +1388,7 @@ int PanoramiXPolyLine(ClientPtr client)
result = (* SavedProcVector[X_PolyLine])(client);
if(result != Success) break;
}
xfree(origPts);
free(origPts);
return (result);
} else
return (client->noClientException);
......@@ -1424,7 +1424,7 @@ int PanoramiXPolySegment(ClientPtr client)
if(nsegs & 4) return BadLength;
nsegs >>= 3;
if (nsegs > 0) {
origSegs = xalloc(nsegs * sizeof(xSegment));
origSegs = malloc(nsegs * sizeof(xSegment));
memcpy((char *) origSegs, (char *) &stuff[1], nsegs * sizeof(xSegment));
FOR_NSCREENS_FORWARD(j){
......@@ -1451,7 +1451,7 @@ int PanoramiXPolySegment(ClientPtr client)
result = (* SavedProcVector[X_PolySegment])(client);
if(result != Success) break;
}
xfree(origSegs);
free(origSegs);
return (result);
} else
return (client->noClientException);
......@@ -1487,7 +1487,7 @@ int PanoramiXPolyRectangle(ClientPtr client)
if(nrects & 4) return BadLength;
nrects >>= 3;
if (nrects > 0){
origRecs = xalloc(nrects * sizeof(xRectangle));
origRecs = malloc(nrects * sizeof(xRectangle));
memcpy((char *)origRecs,(char *)&stuff[1],nrects * sizeof(xRectangle));
FOR_NSCREENS_FORWARD(j){
......@@ -1513,7 +1513,7 @@ int PanoramiXPolyRectangle(ClientPtr client)
result = (* SavedProcVector[X_PolyRectangle])(client);
if(result != Success) break;
}
xfree(origRecs);
free(origRecs);
return (result);
} else
return (client->noClientException);
......@@ -1549,7 +1549,7 @@ int PanoramiXPolyArc(ClientPtr client)
if(narcs % sizeof(xArc)) return BadLength;
narcs /= sizeof(xArc);
if (narcs > 0){
origArcs = xalloc(narcs * sizeof(xArc));
origArcs = malloc(narcs * sizeof(xArc));
memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc));
FOR_NSCREENS_FORWARD(j){
......@@ -1573,7 +1573,7 @@ int PanoramiXPolyArc(ClientPtr client)
result = (* SavedProcVector[X_PolyArc])(client);
if(result != Success) break;
}
xfree(origArcs);
free(origArcs);
return (result);
} else
return (client->noClientException);
......@@ -1607,7 +1607,7 @@ int PanoramiXFillPoly(ClientPtr client)
count = bytes_to_int32((client->req_len << 2) - sizeof(xFillPolyReq));
if (count > 0){
locPts = xalloc(count * sizeof(DDXPointRec));
locPts = malloc(count * sizeof(DDXPointRec));
memcpy((char *)locPts, (char *)&stuff[1], count * sizeof(DDXPointRec));
FOR_NSCREENS_FORWARD(j){
......@@ -1634,7 +1634,7 @@ int PanoramiXFillPoly(ClientPtr client)
result = (* SavedProcVector[X_FillPoly])(client);
if(result != Success) break;
}
xfree(locPts);
free(locPts);
return (result);
} else
return (client->noClientException);
......@@ -1670,7 +1670,7 @@ int PanoramiXPolyFillRectangle(ClientPtr client)
if(things & 4) return BadLength;
things >>= 3;
if (things > 0){
origRects = xalloc(things * sizeof(xRectangle));
origRects = malloc(things * sizeof(xRectangle));
memcpy((char*)origRects,(char*)&stuff[1], things * sizeof(xRectangle));
FOR_NSCREENS_FORWARD(j){
......@@ -1695,7 +1695,7 @@ int PanoramiXPolyFillRectangle(ClientPtr client)
result = (* SavedProcVector[X_PolyFillRectangle])(client);
if(result != Success) break;
}
xfree(origRects);
free(origRects);
return (result);
} else
return (client->noClientException);
......@@ -1731,7 +1731,7 @@ int PanoramiXPolyFillArc(ClientPtr client)
if (narcs % sizeof(xArc)) return BadLength;
narcs /= sizeof(xArc);
if (narcs > 0) {
origArcs = xalloc(narcs * sizeof(xArc));
origArcs = malloc(narcs * sizeof(xArc));
memcpy((char *) origArcs, (char *)&stuff[1], narcs * sizeof(xArc));
FOR_NSCREENS_FORWARD(j){
......@@ -1756,7 +1756,7 @@ int PanoramiXPolyFillArc(ClientPtr client)
result = (* SavedProcVector[X_PolyFillArc])(client);
if(result != Success) break;
}
xfree(origArcs);
free(origArcs);
return (result);
} else
return (client->noClientException);
......@@ -1907,7 +1907,7 @@ int PanoramiXGetImage(ClientPtr client)
linesPerBuf = h;
}
length = linesPerBuf * widthBytesLine;
if(!(pBuf = xalloc(length)))
if(!(pBuf = malloc(length)))
return (BadAlloc);
WriteReplyToClient(client, sizeof (xGetImageReply), &xgi);
......@@ -1953,7 +1953,7 @@ int PanoramiXGetImage(ClientPtr client)
}
}
}
xfree(pBuf);
free(pBuf);
return (client->noClientException);
}
......@@ -2141,7 +2141,7 @@ int PanoramiXCreateColormap(ClientPtr client)
if (result != Success)
return (result == BadValue) ? BadWindow : result;
if(!(newCmap = xalloc(sizeof(PanoramiXRes))))
if(!(newCmap = malloc(sizeof(PanoramiXRes))))
return BadAlloc;
newCmap->type = XRT_COLORMAP;
......@@ -2161,7 +2161,7 @@ int PanoramiXCreateColormap(ClientPtr client)
if (result == Success)
AddResource(newCmap->info[0].id, XRT_COLORMAP, newCmap);
else
xfree(newCmap);
free(newCmap);
return (result);
}
......@@ -2212,7 +2212,7 @@ PanoramiXCopyColormapAndFree(ClientPtr client)
if (result != Success)
return (result == BadValue) ? BadColor : result;
if(!(newCmap = xalloc(sizeof(PanoramiXRes))))
if(!(newCmap = malloc(sizeof(PanoramiXRes))))
return BadAlloc;
newCmap->type = XRT_COLORMAP;
......@@ -2230,7 +2230,7 @@ PanoramiXCopyColormapAndFree(ClientPtr client)
if (result == Success)
AddResource(newCmap->info[0].id, XRT_COLORMAP, newCmap);
else
xfree(newCmap);
free(newCmap);
return (result);
}
......
......@@ -235,7 +235,7 @@ static DevPrivateKey ScreenPrivateKey = &ScreenPrivateKeyIndex;
dixSetPrivate(&(s)->devPrivates, ScreenPrivateKey, v);
#define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = (s ? GetScreenPrivate(s) : NULL)
#define New(t) (xalloc (sizeof (t)))
#define New(t) (malloc(sizeof (t)))
/****************
* ScreenSaverExtensionInit
......@@ -283,7 +283,7 @@ CheckScreenPrivate (ScreenPtr pScreen)
if (!pPriv->attr && !pPriv->events &&
!pPriv->hasWindow && pPriv->installedMap == None)
{
xfree (pPriv);
free(pPriv);
SetScreenPrivate (pScreen, NULL);
savedScreenInfo[pScreen->myNum].ExternalScreenSaver = NULL;
}
......@@ -343,7 +343,7 @@ setEventMask (ScreenPtr pScreen, ClientPtr client, unsigned long mask)
{
FreeResource (pEv->resource, SaverEventType);
*pPrev = pEv->next;
xfree (pEv);
free(pEv);
CheckScreenPrivate (pScreen);
}
else
......@@ -387,8 +387,8 @@ static void
FreeScreenAttr (ScreenSaverAttrPtr pAttr)
{
FreeAttrs (pAttr);
xfree (pAttr->values);
xfree (pAttr);
free(pAttr->values);
free(pAttr);
}
static int
......@@ -407,7 +407,7 @@ ScreenSaverFreeEvents (pointer value, XID id)
if (!pEv)
return TRUE;
*pPrev = pEv->next;
xfree (pEv);
free(pEv);
CheckScreenPrivate (pScreen);
return TRUE;
}
......@@ -446,7 +446,7 @@ ScreenSaverFreeSuspend (pointer value, XID id)
if (this == data)
{
*prev = this->next;
xfree (this);
free(this);
break;
}
}
......@@ -644,14 +644,14 @@ CreateSaverWindow (ScreenPtr pScreen)
wantMap = wColormap (pWin);
if (wantMap == None)
return TRUE;
installedMaps = xalloc (pScreen->maxInstalledCmaps * sizeof (Colormap));
installedMaps = malloc(pScreen->maxInstalledCmaps * sizeof (Colormap));
numInstalled = (*pWin->drawable.pScreen->ListInstalledColormaps)
(pScreen, installedMaps);
for (i = 0; i < numInstalled; i++)
if (installedMaps[i] == wantMap)
break;
xfree ((char *) installedMaps);
free((char *) installedMaps);
if (i < numInstalled)
return TRUE;
......@@ -982,7 +982,7 @@ ScreenSaverSetAttributes (ClientPtr client)
goto bail;
}
/* over allocate for override redirect */
values = xalloc ((len + 1) * sizeof (unsigned long));
values = malloc((len + 1) * sizeof (unsigned long));
if (!values)
{
ret = BadAlloc;
......@@ -1219,8 +1219,8 @@ PatchUp:
FreeAttrs (pAttr);
bail:
CheckScreenPrivate (pScreen);
if (pAttr) xfree (pAttr->values);
xfree (pAttr);
if (pAttr) free(pAttr->values);
free(pAttr);
return ret;
}
......@@ -1392,7 +1392,7 @@ ProcScreenSaverSuspend (ClientPtr client)
* to the record, so the screensaver will be reenabled and the record freed
* if the client disconnects without reenabling it first.
*/
this = xalloc (sizeof (ScreenSaverSuspensionRec));
this = malloc(sizeof (ScreenSaverSuspensionRec));
if (!this)
return BadAlloc;
......@@ -1404,7 +1404,7 @@ ProcScreenSaverSuspend (ClientPtr client)
if (!AddResource (this->clientResource, SuspendType, (pointer) this))
{
xfree (this);
free(this);
return BadAlloc;
}
......
......@@ -222,7 +222,7 @@ SecurityDeleteAuthorization(
}
SecurityAudit("revoked authorization ID %d\n", pAuth->id);
xfree(pAuth);
free(pAuth);
return Success;
} /* SecurityDeleteAuthorization */
......@@ -247,7 +247,7 @@ SecurityDeleteAuthorizationEventClient(
prev->next = pEventClient->next;
else
pAuth->eventClients = pEventClient->next;
xfree(pEventClient);
free(pEventClient);
return(Success);
}
prev = pEventClient;
......@@ -409,7 +409,7 @@ SecurityEventSelectForAuthorization(
}
}
pEventClient = xalloc(sizeof(OtherClients));
pEventClient = malloc(sizeof(OtherClients));
if (!pEventClient)
return BadAlloc;
pEventClient->mask = mask;
......@@ -418,7 +418,7 @@ SecurityEventSelectForAuthorization(
if (!AddResource(pEventClient->resource, RTEventClient,
(pointer)pAuth))
{
xfree(pEventClient);
free(pEventClient);
return BadAlloc;
}
pAuth->eventClients = pEventClient;
......@@ -541,7 +541,7 @@ ProcSecurityGenerateAuthorization(
/* associate additional information with this auth ID */
pAuth = xalloc(sizeof(SecurityAuthorizationRec));
pAuth = malloc(sizeof(SecurityAuthorizationRec));
if (!pAuth)
{
err = BadAlloc;
......@@ -613,7 +613,7 @@ bailout:
if (removeAuth)
RemoveAuthorization(stuff->nbytesAuthProto, protoname,
authdata_len, pAuthdata);
if (pAuth) xfree(pAuth);
if (pAuth) free(pAuth);
return err;
} /* ProcSecurityGenerateAuthorization */
......
......@@ -764,7 +764,7 @@ ShapeFreeClient (pointer data, XID id)
*pHead = pShapeEvent->next;
}
}
xfree ((pointer) pShapeEvent);
free((pointer) pShapeEvent);
return 1;
}
......@@ -778,9 +778,9 @@ ShapeFreeEvents (pointer data, XID id)
for (pCur = *pHead; pCur; pCur = pNext) {
pNext = pCur->next;
FreeResource (pCur->clientResource, ClientType);
xfree ((pointer) pCur);
free((pointer) pCur);
}
xfree ((pointer) pHead);
free((pointer) pHead);
return 1;
}
......@@ -817,7 +817,7 @@ ProcShapeSelectInput (ClientPtr client)
}
/* build the entry */
pNewShapeEvent = xalloc (sizeof (ShapeEventRec));
pNewShapeEvent = malloc(sizeof (ShapeEventRec));
if (!pNewShapeEvent)
return BadAlloc;
pNewShapeEvent->next = 0;
......@@ -839,7 +839,7 @@ ProcShapeSelectInput (ClientPtr client)
*/
if (!pHead)
{
pHead = xalloc (sizeof (ShapeEventPtr));
pHead = malloc(sizeof (ShapeEventPtr));
if (!pHead ||
!AddResource (pWin->drawable.id, ShapeEventType, (pointer)pHead))
{
......@@ -866,7 +866,7 @@ ProcShapeSelectInput (ClientPtr client)
pNewShapeEvent->next = pShapeEvent->next;
else
*pHead = pShapeEvent->next;
xfree (pShapeEvent);
free(pShapeEvent);
}
}
break;
...