mirror of
https://github.com/X11Libre/xserver.git
synced 2026-04-14 17:18:09 +00:00
dix: ProcAllocColorCells(): use x_rpcbuf_t
Use x_rpcbuf_t for payload assembly and X_SEND_REPLY_WITH_RPCBUF() for sending it all out. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
committed by
Enrico Weigelt
parent
59e74c0a1b
commit
0ca53c6908
@@ -2684,14 +2684,17 @@ ProcAllocColorCells(ClientPtr client)
|
||||
}
|
||||
nmasks = stuff->planes;
|
||||
length = ((long) npixels + (long) nmasks) * sizeof(Pixel);
|
||||
Pixel *ppixels = calloc(1, length);
|
||||
|
||||
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
|
||||
|
||||
Pixel *ppixels = x_rpcbuf_reserve(&rpcbuf, length);
|
||||
if (!ppixels)
|
||||
return BadAlloc;
|
||||
pmasks = ppixels + npixels;
|
||||
|
||||
if ((rc = AllocColorCells(client, pcmp, npixels, nmasks,
|
||||
(Bool) stuff->contiguous, ppixels, pmasks))) {
|
||||
free(ppixels);
|
||||
x_rpcbuf_clear(&rpcbuf);
|
||||
return rc;
|
||||
}
|
||||
#ifdef XINERAMA
|
||||
@@ -2699,23 +2702,18 @@ ProcAllocColorCells(ClientPtr client)
|
||||
#endif /* XINERAMA */
|
||||
{
|
||||
xAllocColorCellsReply rep = {
|
||||
.type = X_Reply,
|
||||
.sequenceNumber = client->sequence,
|
||||
.length = bytes_to_int32(length),
|
||||
.nPixels = npixels,
|
||||
.nMasks = nmasks
|
||||
};
|
||||
if (client->swapped) {
|
||||
swaps(&rep.sequenceNumber);
|
||||
swapl(&rep.length);
|
||||
swaps(&rep.nPixels);
|
||||
swaps(&rep.nMasks);
|
||||
SwapLongs(ppixels, length / 4);
|
||||
}
|
||||
WriteToClient(client, sizeof(rep), &rep);
|
||||
WriteToClient(client, length, ppixels);
|
||||
|
||||
return X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf);
|
||||
}
|
||||
free(ppixels);
|
||||
x_rpcbuf_clear(&rpcbuf);
|
||||
return Success;
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user