xkb: ProcXkbGetDeviceInfo(): consolidate buffers to reduce writes
Putting both payload pieces into one buffer, so it can be written out with only one call. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
dff3e38a67
commit
b3a47dcbc4
29
xkb/xkb.c
29
xkb/xkb.c
|
@ -6382,7 +6382,6 @@ ProcXkbGetDeviceInfo(ClientPtr client)
|
|||
unsigned length, nameLen;
|
||||
CARD16 ledClass, ledID;
|
||||
unsigned wanted;
|
||||
char *str;
|
||||
|
||||
REQUEST(xkbGetDeviceInfoReq);
|
||||
REQUEST_SIZE_MATCH(xkbGetDeviceInfoReq);
|
||||
|
@ -6484,23 +6483,25 @@ ProcXkbGetDeviceInfo(ClientPtr client)
|
|||
}
|
||||
WriteToClient(client, SIZEOF(xkbGetDeviceInfoReply), &rep);
|
||||
|
||||
str = malloc(nameLen);
|
||||
if (!str)
|
||||
int sz = nameLen + rep.nBtnsRtrn * sizeof(xkbActionWireDesc);
|
||||
char *buf = calloc(1, sz);
|
||||
if (!buf)
|
||||
return BadAlloc;
|
||||
XkbWriteCountedString(str, dev->name, client->swapped);
|
||||
WriteToClient(client, nameLen, str);
|
||||
free(str);
|
||||
length -= nameLen;
|
||||
char *walk = buf;
|
||||
|
||||
XkbWriteCountedString(walk, dev->name, client->swapped);
|
||||
walk += nameLen;
|
||||
|
||||
if (rep.nBtnsRtrn > 0) {
|
||||
int sz;
|
||||
xkbActionWireDesc *awire;
|
||||
|
||||
sz = rep.nBtnsRtrn * SIZEOF(xkbActionWireDesc);
|
||||
awire = (xkbActionWireDesc *) &dev->button->xkb_acts[rep.firstBtnRtrn];
|
||||
WriteToClient(client, sz, awire);
|
||||
length -= sz;
|
||||
memcpy(walk,
|
||||
&dev->button->xkb_acts[rep.firstBtnRtrn],
|
||||
sizeof(xkbActionWireDesc)*rep.nBtnsRtrn);
|
||||
walk += sizeof(xkbActionWireDesc)*rep.nBtnsRtrn;
|
||||
}
|
||||
|
||||
WriteToClient(client, sz, buf);
|
||||
length -= sz;
|
||||
|
||||
if (nDeviceLedFBs > 0) {
|
||||
status = SendDeviceLedFBs(dev, ledClass, ledID, length, client);
|
||||
if (status != Success)
|
||||
|
|
Loading…
Reference in New Issue