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:
114
render/render.c
114
render/render.c
@@ -375,7 +375,7 @@ ProcRenderQueryPictFormats (ClientPtr client)
|
||||
ndepth * sizeof (xPictDepth) +
|
||||
nvisual * sizeof (xPictVisual) +
|
||||
numSubpixel * sizeof (CARD32));
|
||||
reply = (xRenderQueryPictFormatsReply *) xcalloc (1, rlength);
|
||||
reply = (xRenderQueryPictFormatsReply *) calloc(1, rlength);
|
||||
if (!reply)
|
||||
return BadAlloc;
|
||||
reply->type = X_Reply;
|
||||
@@ -512,7 +512,7 @@ ProcRenderQueryPictFormats (ClientPtr client)
|
||||
swapl (&reply->numSubpixel, n);
|
||||
}
|
||||
WriteToClient(client, rlength, (char *) reply);
|
||||
xfree (reply);
|
||||
free(reply);
|
||||
return client->noClientException;
|
||||
}
|
||||
|
||||
@@ -542,7 +542,7 @@ ProcRenderQueryPictIndexValues (ClientPtr client)
|
||||
num = pFormat->index.nvalues;
|
||||
rlength = (sizeof (xRenderQueryPictIndexValuesReply) +
|
||||
num * sizeof(xIndexValue));
|
||||
reply = (xRenderQueryPictIndexValuesReply *) xalloc (rlength);
|
||||
reply = (xRenderQueryPictIndexValuesReply *) malloc(rlength);
|
||||
if (!reply)
|
||||
return BadAlloc;
|
||||
|
||||
@@ -571,7 +571,7 @@ ProcRenderQueryPictIndexValues (ClientPtr client)
|
||||
}
|
||||
|
||||
WriteToClient(client, rlength, (char *) reply);
|
||||
xfree(reply);
|
||||
free(reply);
|
||||
return (client->noClientException);
|
||||
}
|
||||
|
||||
@@ -1058,7 +1058,7 @@ ProcRenderAddGlyphs (ClientPtr client)
|
||||
}
|
||||
else
|
||||
{
|
||||
glyphsBase = (GlyphNewPtr) Xcalloc (nglyphs * sizeof (GlyphNewRec));
|
||||
glyphsBase = (GlyphNewPtr)calloc(nglyphs, sizeof (GlyphNewRec));
|
||||
if (!glyphsBase)
|
||||
return BadAlloc;
|
||||
}
|
||||
@@ -1200,7 +1200,7 @@ ProcRenderAddGlyphs (ClientPtr client)
|
||||
AddGlyph (glyphSet, glyphs[i].glyph, glyphs[i].id);
|
||||
|
||||
if (glyphsBase != glyphsLocal)
|
||||
Xfree (glyphsBase);
|
||||
free(glyphsBase);
|
||||
return client->noClientException;
|
||||
bail:
|
||||
if (pSrc)
|
||||
@@ -1209,9 +1209,9 @@ bail:
|
||||
FreeScratchPixmapHeader (pSrcPix);
|
||||
for (i = 0; i < nglyphs; i++)
|
||||
if (glyphs[i].glyph && ! glyphs[i].found)
|
||||
xfree (glyphs[i].glyph);
|
||||
free(glyphs[i].glyph);
|
||||
if (glyphsBase != glyphsLocal)
|
||||
Xfree (glyphsBase);
|
||||
free(glyphsBase);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -1335,7 +1335,7 @@ ProcRenderCompositeGlyphs (ClientPtr client)
|
||||
glyphsBase = glyphsLocal;
|
||||
else
|
||||
{
|
||||
glyphsBase = (GlyphPtr *) xalloc (nglyph * sizeof (GlyphPtr));
|
||||
glyphsBase = (GlyphPtr *) malloc(nglyph * sizeof (GlyphPtr));
|
||||
if (!glyphsBase)
|
||||
return BadAlloc;
|
||||
}
|
||||
@@ -1343,7 +1343,7 @@ ProcRenderCompositeGlyphs (ClientPtr client)
|
||||
listsBase = listsLocal;
|
||||
else
|
||||
{
|
||||
listsBase = (GlyphListPtr) xalloc (nlist * sizeof (GlyphListRec));
|
||||
listsBase = (GlyphListPtr) malloc(nlist * sizeof (GlyphListRec));
|
||||
if (!listsBase)
|
||||
return BadAlloc;
|
||||
}
|
||||
@@ -1366,9 +1366,9 @@ ProcRenderCompositeGlyphs (ClientPtr client)
|
||||
if (rc != Success)
|
||||
{
|
||||
if (glyphsBase != glyphsLocal)
|
||||
xfree (glyphsBase);
|
||||
free(glyphsBase);
|
||||
if (listsBase != listsLocal)
|
||||
xfree (listsBase);
|
||||
free(listsBase);
|
||||
return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
|
||||
}
|
||||
}
|
||||
@@ -1422,9 +1422,9 @@ ProcRenderCompositeGlyphs (ClientPtr client)
|
||||
glyphsBase);
|
||||
|
||||
if (glyphsBase != glyphsLocal)
|
||||
xfree (glyphsBase);
|
||||
free(glyphsBase);
|
||||
if (listsBase != listsLocal)
|
||||
xfree (listsBase);
|
||||
free(listsBase);
|
||||
|
||||
return client->noClientException;
|
||||
}
|
||||
@@ -1518,23 +1518,23 @@ ProcRenderCreateCursor (ClientPtr client)
|
||||
if ( stuff->x > width
|
||||
|| stuff->y > height )
|
||||
return (BadMatch);
|
||||
argbbits = xalloc (width * height * sizeof (CARD32));
|
||||
argbbits = malloc(width * height * sizeof (CARD32));
|
||||
if (!argbbits)
|
||||
return (BadAlloc);
|
||||
|
||||
stride = BitmapBytePad(width);
|
||||
nbytes_mono = stride*height;
|
||||
srcbits = xcalloc(1, nbytes_mono);
|
||||
srcbits = calloc(1, nbytes_mono);
|
||||
if (!srcbits)
|
||||
{
|
||||
xfree (argbbits);
|
||||
free(argbbits);
|
||||
return (BadAlloc);
|
||||
}
|
||||
mskbits = xcalloc(1, nbytes_mono);
|
||||
mskbits = calloc(1, nbytes_mono);
|
||||
if (!mskbits)
|
||||
{
|
||||
xfree(argbbits);
|
||||
xfree(srcbits);
|
||||
free(argbbits);
|
||||
free(srcbits);
|
||||
return (BadAlloc);
|
||||
}
|
||||
|
||||
@@ -1554,27 +1554,27 @@ ProcRenderCreateCursor (ClientPtr client)
|
||||
pFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8);
|
||||
if (!pFormat)
|
||||
{
|
||||
xfree (argbbits);
|
||||
xfree (srcbits);
|
||||
xfree (mskbits);
|
||||
free(argbbits);
|
||||
free(srcbits);
|
||||
free(mskbits);
|
||||
return (BadImplementation);
|
||||
}
|
||||
pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, 32,
|
||||
CREATE_PIXMAP_USAGE_SCRATCH);
|
||||
if (!pPixmap)
|
||||
{
|
||||
xfree (argbbits);
|
||||
xfree (srcbits);
|
||||
xfree (mskbits);
|
||||
free(argbbits);
|
||||
free(srcbits);
|
||||
free(mskbits);
|
||||
return (BadAlloc);
|
||||
}
|
||||
pPicture = CreatePicture (0, &pPixmap->drawable, pFormat, 0, 0,
|
||||
client, &error);
|
||||
if (!pPicture)
|
||||
{
|
||||
xfree (argbbits);
|
||||
xfree (srcbits);
|
||||
xfree (mskbits);
|
||||
free(argbbits);
|
||||
free(srcbits);
|
||||
free(mskbits);
|
||||
return error;
|
||||
}
|
||||
(*pScreen->DestroyPixmap) (pPixmap);
|
||||
@@ -1658,7 +1658,7 @@ ProcRenderCreateCursor (ClientPtr client)
|
||||
}
|
||||
else
|
||||
{
|
||||
xfree (argbbits);
|
||||
free(argbbits);
|
||||
argbbits = 0;
|
||||
}
|
||||
|
||||
@@ -1735,7 +1735,7 @@ ProcRenderQueryFilters (ClientPtr client)
|
||||
}
|
||||
len = ((nnames + 1) >> 1) + bytes_to_int32(nbytesName);
|
||||
total_bytes = sizeof (xRenderQueryFiltersReply) + (len << 2);
|
||||
reply = (xRenderQueryFiltersReply *) xalloc (total_bytes);
|
||||
reply = (xRenderQueryFiltersReply *) malloc(total_bytes);
|
||||
if (!reply)
|
||||
return BadAlloc;
|
||||
aliases = (INT16 *) (reply + 1);
|
||||
@@ -1806,7 +1806,7 @@ ProcRenderQueryFilters (ClientPtr client)
|
||||
swapl(&reply->numFilters, n);
|
||||
}
|
||||
WriteToClient(client, total_bytes, (char *) reply);
|
||||
xfree (reply);
|
||||
free(reply);
|
||||
|
||||
return(client->noClientException);
|
||||
}
|
||||
@@ -1847,7 +1847,7 @@ ProcRenderCreateAnimCursor (ClientPtr client)
|
||||
if (client->req_len & 1)
|
||||
return BadLength;
|
||||
ncursor = (client->req_len - (bytes_to_int32(sizeof(xRenderCreateAnimCursorReq)))) >> 1;
|
||||
cursors = xalloc (ncursor * (sizeof (CursorPtr) + sizeof (CARD32)));
|
||||
cursors = malloc(ncursor * (sizeof (CursorPtr) + sizeof (CARD32)));
|
||||
if (!cursors)
|
||||
return BadAlloc;
|
||||
deltas = (CARD32 *) (cursors + ncursor);
|
||||
@@ -1858,7 +1858,7 @@ ProcRenderCreateAnimCursor (ClientPtr client)
|
||||
RT_CURSOR, client, DixReadAccess);
|
||||
if (ret != Success)
|
||||
{
|
||||
xfree (cursors);
|
||||
free(cursors);
|
||||
return (ret == BadValue) ? BadCursor : ret;
|
||||
}
|
||||
deltas[i] = elt->delay;
|
||||
@@ -1866,7 +1866,7 @@ ProcRenderCreateAnimCursor (ClientPtr client)
|
||||
}
|
||||
ret = AnimCursorCreate (cursors, deltas, ncursor, &pCursor, client,
|
||||
stuff->cid);
|
||||
xfree (cursors);
|
||||
free(cursors);
|
||||
if (ret != Success)
|
||||
return ret;
|
||||
|
||||
@@ -2669,7 +2669,7 @@ PanoramiXRenderCreatePicture (ClientPtr client)
|
||||
XRC_DRAWABLE, client, DixWriteAccess);
|
||||
if (result != Success)
|
||||
return (result == BadValue) ? BadDrawable : result;
|
||||
if(!(newPict = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
|
||||
if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
|
||||
return BadAlloc;
|
||||
newPict->type = XRT_PICTURE;
|
||||
newPict->info[0].id = stuff->pid;
|
||||
@@ -2695,7 +2695,7 @@ PanoramiXRenderCreatePicture (ClientPtr client)
|
||||
if (result == Success)
|
||||
AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
|
||||
else
|
||||
xfree(newPict);
|
||||
free(newPict);
|
||||
|
||||
return (result);
|
||||
}
|
||||
@@ -2905,7 +2905,7 @@ PanoramiXRenderFillRectangles (ClientPtr client)
|
||||
VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess);
|
||||
extra_len = (client->req_len << 2) - sizeof (xRenderFillRectanglesReq);
|
||||
if (extra_len &&
|
||||
(extra = (char *) xalloc (extra_len)))
|
||||
(extra = (char *) malloc(extra_len)))
|
||||
{
|
||||
memcpy (extra, stuff + 1, extra_len);
|
||||
FOR_NSCREENS_FORWARD(j) {
|
||||
@@ -2931,7 +2931,7 @@ PanoramiXRenderFillRectangles (ClientPtr client)
|
||||
result = (*PanoramiXSaveRenderVector[X_RenderFillRectangles]) (client);
|
||||
if(result != Success) break;
|
||||
}
|
||||
xfree(extra);
|
||||
free(extra);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -2954,7 +2954,7 @@ PanoramiXRenderTrapezoids(ClientPtr client)
|
||||
extra_len = (client->req_len << 2) - sizeof (xRenderTrapezoidsReq);
|
||||
|
||||
if (extra_len &&
|
||||
(extra = (char *) xalloc (extra_len))) {
|
||||
(extra = (char *) malloc(extra_len))) {
|
||||
memcpy (extra, stuff + 1, extra_len);
|
||||
|
||||
FOR_NSCREENS_FORWARD(j) {
|
||||
@@ -2991,7 +2991,7 @@ PanoramiXRenderTrapezoids(ClientPtr client)
|
||||
if(result != Success) break;
|
||||
}
|
||||
|
||||
xfree(extra);
|
||||
free(extra);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -3014,7 +3014,7 @@ PanoramiXRenderTriangles(ClientPtr client)
|
||||
extra_len = (client->req_len << 2) - sizeof (xRenderTrianglesReq);
|
||||
|
||||
if (extra_len &&
|
||||
(extra = (char *) xalloc (extra_len))) {
|
||||
(extra = (char *) malloc(extra_len))) {
|
||||
memcpy (extra, stuff + 1, extra_len);
|
||||
|
||||
FOR_NSCREENS_FORWARD(j) {
|
||||
@@ -3047,7 +3047,7 @@ PanoramiXRenderTriangles(ClientPtr client)
|
||||
if(result != Success) break;
|
||||
}
|
||||
|
||||
xfree(extra);
|
||||
free(extra);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -3070,7 +3070,7 @@ PanoramiXRenderTriStrip(ClientPtr client)
|
||||
extra_len = (client->req_len << 2) - sizeof (xRenderTriStripReq);
|
||||
|
||||
if (extra_len &&
|
||||
(extra = (char *) xalloc (extra_len))) {
|
||||
(extra = (char *) malloc(extra_len))) {
|
||||
memcpy (extra, stuff + 1, extra_len);
|
||||
|
||||
FOR_NSCREENS_FORWARD(j) {
|
||||
@@ -3099,7 +3099,7 @@ PanoramiXRenderTriStrip(ClientPtr client)
|
||||
if(result != Success) break;
|
||||
}
|
||||
|
||||
xfree(extra);
|
||||
free(extra);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -3122,7 +3122,7 @@ PanoramiXRenderTriFan(ClientPtr client)
|
||||
extra_len = (client->req_len << 2) - sizeof (xRenderTriFanReq);
|
||||
|
||||
if (extra_len &&
|
||||
(extra = (char *) xalloc (extra_len))) {
|
||||
(extra = (char *) malloc(extra_len))) {
|
||||
memcpy (extra, stuff + 1, extra_len);
|
||||
|
||||
FOR_NSCREENS_FORWARD(j) {
|
||||
@@ -3151,7 +3151,7 @@ PanoramiXRenderTriFan(ClientPtr client)
|
||||
if(result != Success) break;
|
||||
}
|
||||
|
||||
xfree(extra);
|
||||
free(extra);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -3171,7 +3171,7 @@ PanoramiXRenderAddTraps (ClientPtr client)
|
||||
VERIFY_XIN_PICTURE (picture, stuff->picture, client, DixWriteAccess);
|
||||
extra_len = (client->req_len << 2) - sizeof (xRenderAddTrapsReq);
|
||||
if (extra_len &&
|
||||
(extra = (char *) xalloc (extra_len)))
|
||||
(extra = (char *) malloc(extra_len)))
|
||||
{
|
||||
memcpy (extra, stuff + 1, extra_len);
|
||||
x_off = stuff->xOff;
|
||||
@@ -3188,7 +3188,7 @@ PanoramiXRenderAddTraps (ClientPtr client)
|
||||
result = (*PanoramiXSaveRenderVector[X_RenderAddTraps]) (client);
|
||||
if(result != Success) break;
|
||||
}
|
||||
xfree(extra);
|
||||
free(extra);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -3203,7 +3203,7 @@ PanoramiXRenderCreateSolidFill (ClientPtr client)
|
||||
|
||||
REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq);
|
||||
|
||||
if(!(newPict = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
|
||||
if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
|
||||
return BadAlloc;
|
||||
|
||||
newPict->type = XRT_PICTURE;
|
||||
@@ -3222,7 +3222,7 @@ PanoramiXRenderCreateSolidFill (ClientPtr client)
|
||||
if (result == Success)
|
||||
AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
|
||||
else
|
||||
xfree(newPict);
|
||||
free(newPict);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -3236,7 +3236,7 @@ PanoramiXRenderCreateLinearGradient (ClientPtr client)
|
||||
|
||||
REQUEST_AT_LEAST_SIZE(xRenderCreateLinearGradientReq);
|
||||
|
||||
if(!(newPict = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
|
||||
if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
|
||||
return BadAlloc;
|
||||
|
||||
newPict->type = XRT_PICTURE;
|
||||
@@ -3255,7 +3255,7 @@ PanoramiXRenderCreateLinearGradient (ClientPtr client)
|
||||
if (result == Success)
|
||||
AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
|
||||
else
|
||||
xfree(newPict);
|
||||
free(newPict);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -3269,7 +3269,7 @@ PanoramiXRenderCreateRadialGradient (ClientPtr client)
|
||||
|
||||
REQUEST_AT_LEAST_SIZE(xRenderCreateRadialGradientReq);
|
||||
|
||||
if(!(newPict = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
|
||||
if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
|
||||
return BadAlloc;
|
||||
|
||||
newPict->type = XRT_PICTURE;
|
||||
@@ -3288,7 +3288,7 @@ PanoramiXRenderCreateRadialGradient (ClientPtr client)
|
||||
if (result == Success)
|
||||
AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
|
||||
else
|
||||
xfree(newPict);
|
||||
free(newPict);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -3302,7 +3302,7 @@ PanoramiXRenderCreateConicalGradient (ClientPtr client)
|
||||
|
||||
REQUEST_AT_LEAST_SIZE(xRenderCreateConicalGradientReq);
|
||||
|
||||
if(!(newPict = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
|
||||
if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
|
||||
return BadAlloc;
|
||||
|
||||
newPict->type = XRT_PICTURE;
|
||||
@@ -3321,7 +3321,7 @@ PanoramiXRenderCreateConicalGradient (ClientPtr client)
|
||||
if (result == Success)
|
||||
AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
|
||||
else
|
||||
xfree(newPict);
|
||||
free(newPict);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user