Xext: xres: ProcXResQueryClientResources() simplify payload write out
Collect the few bits in a local array, so one WriteToClient() call is sufficient. That's also easing further simplifications in upcoming commits. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
3af9346edb
commit
155540afa1
27
Xext/xres.c
27
Xext/xres.c
|
@ -337,28 +337,27 @@ ProcXResQueryClientResources(ClientPtr client)
|
||||||
swapl(&rep.num_types);
|
swapl(&rep.num_types);
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteToClient(client, sizeof(xXResQueryClientResourcesReply), &rep);
|
xXResType *scratch = calloc(sizeof(xXResType), num_types);
|
||||||
|
if (!scratch) {
|
||||||
|
free(counts);
|
||||||
|
return BadAlloc;
|
||||||
|
}
|
||||||
|
|
||||||
if (num_types) {
|
for (int i = 0; i < num_types; i++) {
|
||||||
xXResType scratch;
|
scratch[i].resource_type = resourceTypeAtom(i + 1);
|
||||||
|
scratch[i].count = counts[i];
|
||||||
for (int i = 0; i < lastResourceType; i++) {
|
|
||||||
if (!counts[i])
|
|
||||||
continue;
|
|
||||||
|
|
||||||
scratch.resource_type = resourceTypeAtom(i + 1);
|
|
||||||
scratch.count = counts[i];
|
|
||||||
|
|
||||||
if (client->swapped) {
|
if (client->swapped) {
|
||||||
swapl(&scratch.resource_type);
|
swapl(&scratch[i].resource_type);
|
||||||
swapl(&scratch.count);
|
swapl(&scratch[i].count);
|
||||||
}
|
|
||||||
WriteToClient(client, sz_xXResType, &scratch);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(counts);
|
free(counts);
|
||||||
|
|
||||||
|
WriteToClient(client, sizeof(xXResQueryClientResourcesReply), &rep);
|
||||||
|
WriteToClient(client, sizeof(scratch), scratch);
|
||||||
|
free(scratch);
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue