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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user