mirror of
https://github.com/X11Libre/xserver.git
synced 2026-04-14 17:18:09 +00:00
Xi: ProcXListInputDevices(): use x_rpcbuf_t
use x_rpcbuf_t for reply payload assembly. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
committed by
Enrico Weigelt
parent
6ba9edc2b8
commit
8c90875c3d
32
Xi/listdev.c
32
Xi/listdev.c
@@ -57,7 +57,9 @@ SOFTWARE.
|
||||
#include <X11/extensions/XI.h>
|
||||
#include <X11/extensions/XIproto.h>
|
||||
|
||||
#include "dix/dix_priv.h"
|
||||
#include "dix/input_priv.h"
|
||||
#include "dix/rpcbuf_priv.h"
|
||||
|
||||
#include "inputstr.h" /* DeviceIntPtr */
|
||||
#include "XIstubs.h"
|
||||
@@ -320,7 +322,7 @@ ProcXListInputDevices(ClientPtr client)
|
||||
int namesize = 1; /* need 1 extra byte for strcpy */
|
||||
int i = 0, size = 0;
|
||||
int total_length;
|
||||
char *devbuf, *classbuf, *namebuf, *savbuf;
|
||||
char *classbuf, *namebuf;
|
||||
Bool *skip;
|
||||
xDeviceInfo *dev;
|
||||
DeviceIntPtr d;
|
||||
@@ -352,12 +354,18 @@ ProcXListInputDevices(ClientPtr client)
|
||||
numdevs++;
|
||||
}
|
||||
|
||||
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
|
||||
|
||||
/* allocate space for reply */
|
||||
total_length = numdevs * sizeof(xDeviceInfo) + size + namesize;
|
||||
devbuf = (char *) calloc(1, total_length);
|
||||
char *devbuf = x_rpcbuf_reserve(&rpcbuf, total_length);
|
||||
if (!devbuf) {
|
||||
free(skip);
|
||||
return BadAlloc;
|
||||
}
|
||||
|
||||
classbuf = devbuf + (numdevs * sizeof(xDeviceInfo));
|
||||
namebuf = classbuf + size;
|
||||
savbuf = devbuf;
|
||||
|
||||
/* fill in and send reply */
|
||||
i = 0;
|
||||
@@ -376,22 +384,12 @@ ProcXListInputDevices(ClientPtr client)
|
||||
ListDeviceInfo(client, d, dev++, &devbuf, &classbuf, &namebuf);
|
||||
}
|
||||
|
||||
xListInputDevicesReply rep = {
|
||||
.repType = X_Reply,
|
||||
free(skip);
|
||||
|
||||
xListInputDevicesReply reply = {
|
||||
.RepType = X_ListInputDevices,
|
||||
.sequenceNumber = client->sequence,
|
||||
.ndevices = numdevs,
|
||||
.length = bytes_to_int32(total_length),
|
||||
};
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&rep.sequenceNumber);
|
||||
swapl(&rep.length);
|
||||
}
|
||||
|
||||
WriteToClient(client, sizeof(xListInputDevicesReply), &rep);
|
||||
WriteToClient(client, total_length, savbuf);
|
||||
free(savbuf);
|
||||
free(skip);
|
||||
return Success;
|
||||
return X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user