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 <dottedmag@dottedmag.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
@@ -64,15 +64,15 @@ RRCrtcCreate (ScreenPtr pScreen, void *devPrivate)
|
||||
|
||||
/* make space for the crtc pointer */
|
||||
if (pScrPriv->numCrtcs)
|
||||
crtcs = xrealloc (pScrPriv->crtcs,
|
||||
crtcs = realloc(pScrPriv->crtcs,
|
||||
(pScrPriv->numCrtcs + 1) * sizeof (RRCrtcPtr));
|
||||
else
|
||||
crtcs = xalloc (sizeof (RRCrtcPtr));
|
||||
crtcs = malloc(sizeof (RRCrtcPtr));
|
||||
if (!crtcs)
|
||||
return FALSE;
|
||||
pScrPriv->crtcs = crtcs;
|
||||
|
||||
crtc = xcalloc (1, sizeof (RRCrtcRec));
|
||||
crtc = calloc(1, sizeof (RRCrtcRec));
|
||||
if (!crtc)
|
||||
return NULL;
|
||||
crtc->id = FakeClientID (0);
|
||||
@@ -181,17 +181,17 @@ RRCrtcNotify (RRCrtcPtr crtc,
|
||||
if (numOutputs)
|
||||
{
|
||||
if (crtc->numOutputs)
|
||||
newoutputs = xrealloc (crtc->outputs,
|
||||
newoutputs = realloc(crtc->outputs,
|
||||
numOutputs * sizeof (RROutputPtr));
|
||||
else
|
||||
newoutputs = xalloc (numOutputs * sizeof (RROutputPtr));
|
||||
newoutputs = malloc(numOutputs * sizeof (RROutputPtr));
|
||||
if (!newoutputs)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (crtc->outputs)
|
||||
xfree (crtc->outputs);
|
||||
free(crtc->outputs);
|
||||
newoutputs = NULL;
|
||||
}
|
||||
crtc->outputs = newoutputs;
|
||||
@@ -442,10 +442,10 @@ RRCrtcDestroyResource (pointer value, XID pid)
|
||||
}
|
||||
}
|
||||
if (crtc->gammaRed)
|
||||
xfree (crtc->gammaRed);
|
||||
free(crtc->gammaRed);
|
||||
if (crtc->mode)
|
||||
RRModeDestroy (crtc->mode);
|
||||
xfree (crtc);
|
||||
free(crtc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -558,14 +558,14 @@ RRCrtcGammaSetSize (RRCrtcPtr crtc,
|
||||
return TRUE;
|
||||
if (size)
|
||||
{
|
||||
gamma = xalloc (size * 3 * sizeof (CARD16));
|
||||
gamma = malloc(size * 3 * sizeof (CARD16));
|
||||
if (!gamma)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
gamma = NULL;
|
||||
if (crtc->gammaRed)
|
||||
xfree (crtc->gammaRed);
|
||||
free(crtc->gammaRed);
|
||||
crtc->gammaRed = gamma;
|
||||
crtc->gammaGreen = gamma + size;
|
||||
crtc->gammaBlue = gamma + size*2;
|
||||
@@ -704,7 +704,7 @@ ProcRRGetCrtcInfo (ClientPtr client)
|
||||
extraLen = rep.length << 2;
|
||||
if (extraLen)
|
||||
{
|
||||
extra = xalloc (extraLen);
|
||||
extra = malloc(extraLen);
|
||||
if (!extra)
|
||||
return BadAlloc;
|
||||
}
|
||||
@@ -749,7 +749,7 @@ ProcRRGetCrtcInfo (ClientPtr client)
|
||||
if (extraLen)
|
||||
{
|
||||
WriteToClient (client, extraLen, (char *) extra);
|
||||
xfree (extra);
|
||||
free(extra);
|
||||
}
|
||||
|
||||
return client->noClientException;
|
||||
@@ -791,7 +791,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
|
||||
}
|
||||
if (numOutputs)
|
||||
{
|
||||
outputs = xalloc (numOutputs * sizeof (RROutputPtr));
|
||||
outputs = malloc(numOutputs * sizeof (RROutputPtr));
|
||||
if (!outputs)
|
||||
return BadAlloc;
|
||||
}
|
||||
@@ -806,7 +806,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
|
||||
if (rc != Success)
|
||||
{
|
||||
if (outputs)
|
||||
xfree (outputs);
|
||||
free(outputs);
|
||||
return (rc == BadValue) ? RRErrorBase + BadRROutput : rc;
|
||||
}
|
||||
/* validate crtc for this output */
|
||||
@@ -816,7 +816,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
|
||||
if (j == outputs[i]->numCrtcs)
|
||||
{
|
||||
if (outputs)
|
||||
xfree (outputs);
|
||||
free(outputs);
|
||||
return BadMatch;
|
||||
}
|
||||
/* validate mode for this output */
|
||||
@@ -831,7 +831,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
|
||||
if (j == outputs[i]->numModes + outputs[i]->numUserModes)
|
||||
{
|
||||
if (outputs)
|
||||
xfree (outputs);
|
||||
free(outputs);
|
||||
return BadMatch;
|
||||
}
|
||||
}
|
||||
@@ -851,7 +851,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
|
||||
if (k == outputs[i]->numClones)
|
||||
{
|
||||
if (outputs)
|
||||
xfree (outputs);
|
||||
free(outputs);
|
||||
return BadMatch;
|
||||
}
|
||||
}
|
||||
@@ -901,7 +901,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
|
||||
*/
|
||||
client->errorValue = stuff->rotation;
|
||||
if (outputs)
|
||||
xfree (outputs);
|
||||
free(outputs);
|
||||
return BadValue;
|
||||
}
|
||||
|
||||
@@ -914,7 +914,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
|
||||
*/
|
||||
client->errorValue = stuff->rotation;
|
||||
if (outputs)
|
||||
xfree (outputs);
|
||||
free(outputs);
|
||||
return BadMatch;
|
||||
}
|
||||
|
||||
@@ -944,7 +944,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
|
||||
{
|
||||
client->errorValue = stuff->x;
|
||||
if (outputs)
|
||||
xfree (outputs);
|
||||
free(outputs);
|
||||
return BadValue;
|
||||
}
|
||||
|
||||
@@ -952,7 +952,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
|
||||
{
|
||||
client->errorValue = stuff->y;
|
||||
if (outputs)
|
||||
xfree (outputs);
|
||||
free(outputs);
|
||||
return BadValue;
|
||||
}
|
||||
}
|
||||
@@ -980,7 +980,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
|
||||
|
||||
sendReply:
|
||||
if (outputs)
|
||||
xfree (outputs);
|
||||
free(outputs);
|
||||
|
||||
rep.type = X_Reply;
|
||||
/* rep.status has already been filled in */
|
||||
@@ -1196,7 +1196,7 @@ ProcRRGetCrtcGamma (ClientPtr client)
|
||||
len = crtc->gammaSize * 3 * 2;
|
||||
|
||||
if (crtc->gammaSize) {
|
||||
extra = xalloc(len);
|
||||
extra = malloc(len);
|
||||
if (!extra)
|
||||
return BadAlloc;
|
||||
}
|
||||
@@ -1216,7 +1216,7 @@ ProcRRGetCrtcGamma (ClientPtr client)
|
||||
memcpy(extra, crtc->gammaRed, len);
|
||||
client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write;
|
||||
WriteSwappedDataToClient (client, len, extra);
|
||||
xfree(extra);
|
||||
free(extra);
|
||||
}
|
||||
return client->noClientException;
|
||||
}
|
||||
@@ -1354,7 +1354,7 @@ ProcRRGetCrtcTransform (ClientPtr client)
|
||||
nextra = (transform_filter_length (pending) +
|
||||
transform_filter_length (current));
|
||||
|
||||
reply = xalloc (sizeof (xRRGetCrtcTransformReply) + nextra);
|
||||
reply = malloc(sizeof (xRRGetCrtcTransformReply) + nextra);
|
||||
if (!reply)
|
||||
return BadAlloc;
|
||||
|
||||
@@ -1382,6 +1382,6 @@ ProcRRGetCrtcTransform (ClientPtr client)
|
||||
swapl (&reply->length, n);
|
||||
}
|
||||
WriteToClient (client, sizeof (xRRGetCrtcTransformReply) + nextra, (char *) reply);
|
||||
xfree(reply);
|
||||
free(reply);
|
||||
return client->noClientException;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user