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:
@@ -137,8 +137,8 @@ ProcRotateProperties(ClientPtr client)
|
||||
return rc;
|
||||
|
||||
atoms = (Atom *) & stuff[1];
|
||||
props = xalloc(stuff->nAtoms * sizeof(PropertyPtr));
|
||||
saved = xalloc(stuff->nAtoms * sizeof(PropertyRec));
|
||||
props = malloc(stuff->nAtoms * sizeof(PropertyPtr));
|
||||
saved = malloc(stuff->nAtoms * sizeof(PropertyRec));
|
||||
if (!props || !saved) {
|
||||
rc = BadAlloc;
|
||||
goto out;
|
||||
@@ -188,8 +188,8 @@ ProcRotateProperties(ClientPtr client)
|
||||
}
|
||||
}
|
||||
out:
|
||||
xfree(saved);
|
||||
xfree(props);
|
||||
free(saved);
|
||||
free(props);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -269,13 +269,13 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
|
||||
{
|
||||
if (!pWin->optional && !MakeWindowOptional (pWin))
|
||||
return(BadAlloc);
|
||||
pProp = xalloc(sizeof(PropertyRec));
|
||||
pProp = malloc(sizeof(PropertyRec));
|
||||
if (!pProp)
|
||||
return(BadAlloc);
|
||||
data = xalloc(totalSize);
|
||||
data = malloc(totalSize);
|
||||
if (!data && len)
|
||||
{
|
||||
xfree(pProp);
|
||||
free(pProp);
|
||||
return(BadAlloc);
|
||||
}
|
||||
memcpy(data, value, totalSize);
|
||||
@@ -288,8 +288,8 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
|
||||
rc = XaceHookPropertyAccess(pClient, pWin, &pProp,
|
||||
DixCreateAccess|DixWriteAccess);
|
||||
if (rc != Success) {
|
||||
xfree(data);
|
||||
xfree(pProp);
|
||||
free(data);
|
||||
free(pProp);
|
||||
pClient->errorValue = property;
|
||||
return rc;
|
||||
}
|
||||
@@ -313,7 +313,7 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
|
||||
|
||||
if (mode == PropModeReplace)
|
||||
{
|
||||
data = xalloc(totalSize);
|
||||
data = malloc(totalSize);
|
||||
if (!data && len)
|
||||
return(BadAlloc);
|
||||
memcpy(data, value, totalSize);
|
||||
@@ -328,7 +328,7 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
|
||||
}
|
||||
else if (mode == PropModeAppend)
|
||||
{
|
||||
data = xalloc((pProp->size + len) * sizeInBytes);
|
||||
data = malloc((pProp->size + len) * sizeInBytes);
|
||||
if (!data)
|
||||
return(BadAlloc);
|
||||
memcpy(data, pProp->data, pProp->size * sizeInBytes);
|
||||
@@ -338,7 +338,7 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
|
||||
}
|
||||
else if (mode == PropModePrepend)
|
||||
{
|
||||
data = xalloc(sizeInBytes * (len + pProp->size));
|
||||
data = malloc(sizeInBytes * (len + pProp->size));
|
||||
if (!data)
|
||||
return(BadAlloc);
|
||||
memcpy(data + totalSize, pProp->data, pProp->size * sizeInBytes);
|
||||
@@ -353,12 +353,12 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
|
||||
if (rc == Success)
|
||||
{
|
||||
if (savedProp.data != pProp->data)
|
||||
xfree(savedProp.data);
|
||||
free(savedProp.data);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (savedProp.data != pProp->data)
|
||||
xfree(pProp->data);
|
||||
free(pProp->data);
|
||||
*pProp = savedProp;
|
||||
return rc;
|
||||
}
|
||||
@@ -406,8 +406,8 @@ DeleteProperty(ClientPtr client, WindowPtr pWin, Atom propName)
|
||||
|
||||
deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp->propertyName);
|
||||
dixFreePrivates(pProp->devPrivates);
|
||||
xfree(pProp->data);
|
||||
xfree(pProp);
|
||||
free(pProp->data);
|
||||
free(pProp);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@@ -423,8 +423,8 @@ DeleteAllWindowProperties(WindowPtr pWin)
|
||||
deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp->propertyName);
|
||||
pNextProp = pProp->next;
|
||||
dixFreePrivates(pProp->devPrivates);
|
||||
xfree(pProp->data);
|
||||
xfree(pProp);
|
||||
free(pProp->data);
|
||||
free(pProp);
|
||||
pProp = pNextProp;
|
||||
}
|
||||
}
|
||||
@@ -571,8 +571,8 @@ ProcGetProperty(ClientPtr client)
|
||||
}
|
||||
|
||||
dixFreePrivates(pProp->devPrivates);
|
||||
xfree(pProp->data);
|
||||
xfree(pProp);
|
||||
free(pProp->data);
|
||||
free(pProp);
|
||||
}
|
||||
return(client->noClientException);
|
||||
}
|
||||
@@ -595,7 +595,7 @@ ProcListProperties(ClientPtr client)
|
||||
for (pProp = wUserProps(pWin); pProp; pProp = pProp->next)
|
||||
numProps++;
|
||||
|
||||
if (numProps && !(pAtoms = xalloc(numProps * sizeof(Atom))))
|
||||
if (numProps && !(pAtoms = malloc(numProps * sizeof(Atom))))
|
||||
return BadAlloc;
|
||||
|
||||
numProps = 0;
|
||||
@@ -619,7 +619,7 @@ ProcListProperties(ClientPtr client)
|
||||
client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write;
|
||||
WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms);
|
||||
}
|
||||
xfree(pAtoms);
|
||||
free(pAtoms);
|
||||
return(client->noClientException);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user