xkb: XkbSendCompatMap(): little cleanup and simplification
Make it a bit simpler and easier to read. calloc() and WriteToClient() can handle zero lengths very well. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
d1555edcc2
commit
f3176bae97
25
xkb/xkb.c
25
xkb/xkb.c
|
@ -2806,18 +2806,16 @@ static int
|
|||
XkbSendCompatMap(ClientPtr client,
|
||||
XkbCompatMapPtr compat, xkbGetCompatMapReply rep)
|
||||
{
|
||||
char *data;
|
||||
int size;
|
||||
int sz = rep.length * sizeof(CARD32);
|
||||
char *buf = calloc(1, sz);
|
||||
if (sz && (!buf))
|
||||
return BadAlloc;
|
||||
|
||||
if (rep.length > 0) {
|
||||
data = calloc(rep.length, 4);
|
||||
if (data) {
|
||||
if (sz) {
|
||||
register unsigned i, bit;
|
||||
xkbModsWireDesc *grp;
|
||||
XkbSymInterpretPtr sym = &compat->sym_interpret[rep.firstSI];
|
||||
xkbSymInterpretWireDesc *wire = (xkbSymInterpretWireDesc *) data;
|
||||
|
||||
size = rep.length * 4;
|
||||
xkbSymInterpretWireDesc *wire = (xkbSymInterpretWireDesc *) buf;
|
||||
|
||||
for (i = 0; i < rep.nSI; i++, sym++, wire++) {
|
||||
wire->sym = sym->sym;
|
||||
|
@ -2847,11 +2845,6 @@ XkbSendCompatMap(ClientPtr client,
|
|||
wire = (xkbSymInterpretWireDesc *) grp;
|
||||
}
|
||||
}
|
||||
else
|
||||
return BadAlloc;
|
||||
}
|
||||
else
|
||||
data = NULL;
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&rep.sequenceNumber);
|
||||
|
@ -2862,10 +2855,8 @@ XkbSendCompatMap(ClientPtr client,
|
|||
}
|
||||
|
||||
WriteToClient(client, sizeof(xkbGetCompatMapReply), &rep);
|
||||
if (data) {
|
||||
WriteToClient(client, size, data);
|
||||
free((char *) data);
|
||||
}
|
||||
WriteToClient(client, sz, buf);
|
||||
free(buf);
|
||||
return Success;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue