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:
@@ -196,7 +196,7 @@ CursorCloseScreen (int index, ScreenPtr pScreen)
|
||||
Unwrap (cs, pScreen, DisplayCursor, display_proc);
|
||||
deleteCursorHideCountsForScreen(pScreen);
|
||||
ret = (*pScreen->CloseScreen) (index, pScreen);
|
||||
xfree (cs);
|
||||
free(cs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ XFixesSelectCursorInput (ClientPtr pClient,
|
||||
}
|
||||
if (!e)
|
||||
{
|
||||
e = (CursorEventPtr) xalloc (sizeof (CursorEventRec));
|
||||
e = (CursorEventPtr) malloc(sizeof (CursorEventRec));
|
||||
if (!e)
|
||||
return BadAlloc;
|
||||
|
||||
@@ -249,7 +249,7 @@ XFixesSelectCursorInput (ClientPtr pClient,
|
||||
if (!AddResource (pWindow->drawable.id, CursorWindowType,
|
||||
(pointer) pWindow))
|
||||
{
|
||||
xfree (e);
|
||||
free(e);
|
||||
return BadAlloc;
|
||||
}
|
||||
|
||||
@@ -389,7 +389,7 @@ ProcXFixesGetCursorImage (ClientPtr client)
|
||||
width = pCursor->bits->width;
|
||||
height = pCursor->bits->height;
|
||||
npixels = width * height;
|
||||
rep = xalloc (sizeof (xXFixesGetCursorImageReply) +
|
||||
rep = malloc(sizeof (xXFixesGetCursorImageReply) +
|
||||
npixels * sizeof (CARD32));
|
||||
if (!rep)
|
||||
return BadAlloc;
|
||||
@@ -423,7 +423,7 @@ ProcXFixesGetCursorImage (ClientPtr client)
|
||||
}
|
||||
WriteToClient(client, sizeof (xXFixesGetCursorImageReply) +
|
||||
(npixels << 2), (char *) rep);
|
||||
xfree (rep);
|
||||
free(rep);
|
||||
return client->noClientException;
|
||||
}
|
||||
|
||||
@@ -544,7 +544,7 @@ ProcXFixesGetCursorImageAndName (ClientPtr client)
|
||||
name = pCursor->name ? NameForAtom (pCursor->name) : "";
|
||||
nbytes = strlen (name);
|
||||
nbytesRound = pad_to_int32(nbytes);
|
||||
rep = xalloc (sizeof (xXFixesGetCursorImageAndNameReply) +
|
||||
rep = malloc(sizeof (xXFixesGetCursorImageAndNameReply) +
|
||||
npixels * sizeof (CARD32) + nbytesRound);
|
||||
if (!rep)
|
||||
return BadAlloc;
|
||||
@@ -583,7 +583,7 @@ ProcXFixesGetCursorImageAndName (ClientPtr client)
|
||||
}
|
||||
WriteToClient(client, sizeof (xXFixesGetCursorImageAndNameReply) +
|
||||
(npixels << 2) + nbytesRound, (char *) rep);
|
||||
xfree (rep);
|
||||
free(rep);
|
||||
return client->noClientException;
|
||||
}
|
||||
|
||||
@@ -801,7 +801,7 @@ createCursorHideCount (ClientPtr pClient, ScreenPtr pScreen)
|
||||
CursorScreenPtr cs = GetCursorScreen(pScreen);
|
||||
CursorHideCountPtr pChc;
|
||||
|
||||
pChc = (CursorHideCountPtr) xalloc(sizeof(CursorHideCountRec));
|
||||
pChc = (CursorHideCountPtr) malloc(sizeof(CursorHideCountRec));
|
||||
if (pChc == NULL) {
|
||||
return BadAlloc;
|
||||
}
|
||||
@@ -818,7 +818,7 @@ createCursorHideCount (ClientPtr pClient, ScreenPtr pScreen)
|
||||
*/
|
||||
if (!AddResource (pChc->resource, CursorHideCountType,
|
||||
(pointer) pChc)) {
|
||||
xfree(pChc);
|
||||
free(pChc);
|
||||
return BadAlloc;
|
||||
}
|
||||
|
||||
@@ -839,7 +839,7 @@ deleteCursorHideCount (CursorHideCountPtr pChcToDel, ScreenPtr pScreen)
|
||||
while (pChc != NULL) {
|
||||
pNext = pChc->pNext;
|
||||
if (pChc == pChcToDel) {
|
||||
xfree(pChc);
|
||||
free(pChc);
|
||||
if (pChcLast == NULL) {
|
||||
cs->pCursorHideCounts = pNext;
|
||||
} else {
|
||||
@@ -995,7 +995,7 @@ CursorFreeClient (pointer data, XID id)
|
||||
if (e == old)
|
||||
{
|
||||
*prev = e->next;
|
||||
xfree (e);
|
||||
free(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1043,8 +1043,8 @@ createInvisibleCursor (void)
|
||||
unsigned char *psrcbits, *pmaskbits;
|
||||
CursorMetricRec cm;
|
||||
|
||||
psrcbits = (unsigned char *) xcalloc(4, 1);
|
||||
pmaskbits = (unsigned char *) xcalloc(4, 1);
|
||||
psrcbits = (unsigned char *) calloc(4, 1);
|
||||
pmaskbits = (unsigned char *) calloc(4, 1);
|
||||
if (psrcbits == NULL || pmaskbits == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -1080,7 +1080,7 @@ XFixesCursorInit (void)
|
||||
ScreenPtr pScreen = screenInfo.screens[i];
|
||||
CursorScreenPtr cs;
|
||||
|
||||
cs = (CursorScreenPtr) xalloc (sizeof (CursorScreenRec));
|
||||
cs = (CursorScreenPtr) malloc(sizeof (CursorScreenRec));
|
||||
if (!cs)
|
||||
return FALSE;
|
||||
Wrap (cs, pScreen, CloseScreen, CursorCloseScreen);
|
||||
|
||||
@@ -568,7 +568,7 @@ ProcXFixesFetchRegion (ClientPtr client)
|
||||
pBox = REGION_RECTS (pRegion);
|
||||
nBox = REGION_NUM_RECTS (pRegion);
|
||||
|
||||
reply = xalloc (sizeof (xXFixesFetchRegionReply) +
|
||||
reply = malloc(sizeof (xXFixesFetchRegionReply) +
|
||||
nBox * sizeof (xRectangle));
|
||||
if (!reply)
|
||||
return BadAlloc;
|
||||
@@ -601,7 +601,7 @@ ProcXFixesFetchRegion (ClientPtr client)
|
||||
}
|
||||
(void) WriteToClient(client, sizeof (xXFixesFetchRegionReply) +
|
||||
nBox * sizeof (xRectangle), (char *) reply);
|
||||
xfree (reply);
|
||||
free(reply);
|
||||
return (client->noClientException);
|
||||
}
|
||||
|
||||
@@ -812,7 +812,7 @@ ProcXFixesExpandRegion (ClientPtr client)
|
||||
pSrc = REGION_RECTS(pSource);
|
||||
if (nBoxes)
|
||||
{
|
||||
pTmp = xalloc (nBoxes * sizeof (BoxRec));
|
||||
pTmp = malloc(nBoxes * sizeof (BoxRec));
|
||||
if (!pTmp)
|
||||
return BadAlloc;
|
||||
for (i = 0; i < nBoxes; i++)
|
||||
@@ -829,7 +829,7 @@ ProcXFixesExpandRegion (ClientPtr client)
|
||||
REGION_INIT (pScreen, &r, &pTmp[i], 0);
|
||||
REGION_UNION (pScreen, pDestination, pDestination, &r);
|
||||
}
|
||||
xfree(pTmp);
|
||||
free(pTmp);
|
||||
}
|
||||
if (ret == Success)
|
||||
ret = client->noClientException;
|
||||
|
||||
@@ -160,7 +160,7 @@ XFixesSelectSelectionInput (ClientPtr pClient,
|
||||
}
|
||||
if (!e)
|
||||
{
|
||||
e = (SelectionEventPtr) xalloc (sizeof (SelectionEventRec));
|
||||
e = (SelectionEventPtr) malloc(sizeof (SelectionEventRec));
|
||||
if (!e)
|
||||
return BadAlloc;
|
||||
|
||||
@@ -181,7 +181,7 @@ XFixesSelectSelectionInput (ClientPtr pClient,
|
||||
if (!AddResource (pWindow->drawable.id, SelectionWindowType,
|
||||
(pointer) pWindow))
|
||||
{
|
||||
xfree (e);
|
||||
free(e);
|
||||
return BadAlloc;
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ SelectionFreeClient (pointer data, XID id)
|
||||
if (e == old)
|
||||
{
|
||||
*prev = e->next;
|
||||
xfree (e);
|
||||
free(e);
|
||||
CheckSelectionCallback ();
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user