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
031b93642b
commit
bc22eb32ee
28
xkb/xkb.c
28
xkb/xkb.c
|
@ -6484,23 +6484,25 @@ ProcXkbGetDeviceInfo(ClientPtr client)
|
||||||
}
|
}
|
||||||
WriteToClient(client, SIZEOF(xkbGetDeviceInfoReply), &rep);
|
WriteToClient(client, SIZEOF(xkbGetDeviceInfoReply), &rep);
|
||||||
|
|
||||||
char *str = calloc(1, nameLen);
|
int sz = nameLen + rep.nBtnsRtrn * sizeof(xkbActionWireDesc);
|
||||||
if (!str)
|
char *buf = calloc(1, sz);
|
||||||
|
if (!buf)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
XkbWriteCountedString(str, dev->name, client->swapped);
|
char *walk = buf;
|
||||||
WriteToClient(client, nameLen, str);
|
|
||||||
free(str);
|
XkbWriteCountedString(walk, dev->name, client->swapped);
|
||||||
length -= nameLen;
|
walk += nameLen;
|
||||||
|
|
||||||
if (rep.nBtnsRtrn > 0) {
|
if (rep.nBtnsRtrn > 0) {
|
||||||
int sz;
|
memcpy(walk,
|
||||||
xkbActionWireDesc *awire;
|
&dev->button->xkb_acts[rep.firstBtnRtrn],
|
||||||
|
sizeof(xkbActionWireDesc)*rep.nBtnsRtrn);
|
||||||
sz = rep.nBtnsRtrn * SIZEOF(xkbActionWireDesc);
|
walk += sizeof(xkbActionWireDesc)*rep.nBtnsRtrn;
|
||||||
awire = (xkbActionWireDesc *) &dev->button->xkb_acts[rep.firstBtnRtrn];
|
|
||||||
WriteToClient(client, sz, awire);
|
|
||||||
length -= sz;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WriteToClient(client, sz, buf);
|
||||||
|
length -= sz;
|
||||||
|
|
||||||
if (nDeviceLedFBs > 0) {
|
if (nDeviceLedFBs > 0) {
|
||||||
status = SendDeviceLedFBs(dev, ledClass, ledID, length, client);
|
status = SendDeviceLedFBs(dev, ledClass, ledID, length, client);
|
||||||
if (status != Success)
|
if (status != Success)
|
||||||
|
|
Loading…
Reference in New Issue