dri3: proc_dri3_buffers_from_pixmap(): 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:
Enrico Weigelt, metux IT consult
2025-09-02 17:39:13 +02:00
committed by Enrico Weigelt
parent 065f8d4d75
commit cca0a47af7

View File

@@ -532,19 +532,12 @@ proc_dri3_buffers_from_pixmap(ClientPtr client)
}
}
const size_t bufsz = num_fds * 2 * sizeof(CARD32);
CARD32 *buf = calloc(1, bufsz);
if (!buf)
return BadAlloc;
memcpy(buf, strides, num_fds * sizeof(CARD32));
memcpy(&buf[num_fds], offsets, num_fds * sizeof(CARD32));
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
x_rpcbuf_write_CARD32s(&rpcbuf, strides, num_fds);
x_rpcbuf_write_CARD32s(&rpcbuf, offsets, num_fds);
xDRI3BuffersFromPixmapReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.nfd = num_fds,
.length = bytes_to_int32(bufsz),
.width = pixmap->drawable.width,
.height = pixmap->drawable.height,
.depth = pixmap->drawable.depth,
@@ -553,19 +546,12 @@ proc_dri3_buffers_from_pixmap(ClientPtr client)
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.width);
swaps(&rep.height);
swapll(&rep.modifier);
for (i = 0; i < num_fds * 2; i++)
swapl(&buf[i]);
}
WriteToClient(client, sizeof(rep), &rep);
WriteToClient(client, bufsz, buf);
free(buf);
return Success;
return X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf);
}
static int