randr: simplify reply assembly in ProcRRListProviderProperties()
Moving payload buffer assembly right into the same branch where the buffer is allocated, so making the whole code flow easier to understand. Also moving the byteswap there (when the fields should still be in CPU cache), instead of having some callback doing it much later, so even more simplication. As a nice by-product, that's also reducing some analyzer noise. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
2e05296905
commit
67b78a9f58
|
@ -335,7 +335,7 @@ int
|
||||||
ProcRRListProviderProperties(ClientPtr client)
|
ProcRRListProviderProperties(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xRRListProviderPropertiesReq);
|
REQUEST(xRRListProviderPropertiesReq);
|
||||||
Atom *pAtoms = NULL, *temppAtoms;
|
Atom *pAtoms = NULL;
|
||||||
int numProps = 0;
|
int numProps = 0;
|
||||||
RRProviderPtr provider;
|
RRProviderPtr provider;
|
||||||
RRPropertyPtr prop;
|
RRPropertyPtr prop;
|
||||||
|
@ -346,9 +346,20 @@ ProcRRListProviderProperties(ClientPtr client)
|
||||||
|
|
||||||
for (prop = provider->properties; prop; prop = prop->next)
|
for (prop = provider->properties; prop; prop = prop->next)
|
||||||
numProps++;
|
numProps++;
|
||||||
if (numProps)
|
|
||||||
if (!(pAtoms = xallocarray(numProps, sizeof(Atom))))
|
const Bool swapped = client->swapped;
|
||||||
|
|
||||||
|
if (numProps) {
|
||||||
|
if (!(pAtoms = calloc(numProps, sizeof(Atom))))
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
|
Atom *temppAtoms = pAtoms;
|
||||||
|
for (prop = provider->properties; prop; prop = prop->next) {
|
||||||
|
*temppAtoms = prop->propertyName;
|
||||||
|
if (swapped)
|
||||||
|
swapl(temppAtoms);
|
||||||
|
temppAtoms++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
xRRListProviderPropertiesReply rep = {
|
xRRListProviderPropertiesReply rep = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
|
@ -356,21 +367,16 @@ ProcRRListProviderProperties(ClientPtr client)
|
||||||
.length = bytes_to_int32(numProps * sizeof(Atom)),
|
.length = bytes_to_int32(numProps * sizeof(Atom)),
|
||||||
.nAtoms = numProps
|
.nAtoms = numProps
|
||||||
};
|
};
|
||||||
if (client->swapped) {
|
if (swapped) {
|
||||||
swaps(&rep.sequenceNumber);
|
swaps(&rep.sequenceNumber);
|
||||||
swapl(&rep.length);
|
swapl(&rep.length);
|
||||||
swaps(&rep.nAtoms);
|
swaps(&rep.nAtoms);
|
||||||
}
|
}
|
||||||
temppAtoms = pAtoms;
|
|
||||||
for (prop = provider->properties; prop; prop = prop->next)
|
|
||||||
*temppAtoms++ = prop->propertyName;
|
|
||||||
|
|
||||||
WriteToClient(client, sizeof(xRRListProviderPropertiesReply), (char *) &rep);
|
WriteToClient(client, sizeof(xRRListProviderPropertiesReply), (char *) &rep);
|
||||||
if (numProps) {
|
WriteToClient(client, numProps * sizeof(Atom), pAtoms);
|
||||||
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
|
|
||||||
WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms);
|
|
||||||
free(pAtoms);
|
free(pAtoms);
|
||||||
}
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue