dix: write out X_ListInstalledColormaps reply directly

No need for using a complex callback machinery, if we just move the
little pieces of byte-swapping directly into the request handler.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-04-03 19:36:17 +02:00
parent 1f2cf6fe4b
commit 725bb2d20d
4 changed files with 27 additions and 32 deletions

View File

@ -2572,7 +2572,7 @@ ProcUninstallColormap(ClientPtr client)
int int
ProcListInstalledColormaps(ClientPtr client) ProcListInstalledColormaps(ClientPtr client)
{ {
int nummaps, rc; int rc;
WindowPtr pWin; WindowPtr pWin;
REQUEST(xResourceReq); REQUEST(xResourceReq);
@ -2586,23 +2586,33 @@ ProcListInstalledColormaps(ClientPtr client)
if (rc != Success) if (rc != Success)
return rc; return rc;
xListInstalledColormapsReply *preply = calloc(1, Colormap *cm = calloc(pWin->drawable.pScreen->maxInstalledCmaps,
sizeof(xListInstalledColormapsReply) + sizeof(Colormap));
pWin->drawable.pScreen->maxInstalledCmaps * if (!cm)
sizeof(Colormap));
if (!preply)
return BadAlloc; return BadAlloc;
preply->type = X_Reply; const ScreenPtr pScreen = pWin->drawable.pScreen;
preply->sequenceNumber = client->sequence; const int nummaps = pScreen->ListInstalledColormaps(pScreen, cm);
nummaps = (*pWin->drawable.pScreen->ListInstalledColormaps)
(pWin->drawable.pScreen, (Colormap *) &preply[1]); xListInstalledColormapsReply rep = {
preply->nColormaps = nummaps; .type = X_Reply,
preply->length = nummaps; .sequenceNumber = client->sequence,
WriteReplyToClient(client, sizeof(xListInstalledColormapsReply), preply); .nColormaps = nummaps,
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; .length = nummaps,
WriteSwappedDataToClient(client, nummaps * sizeof(Colormap), &preply[1]); };
free(preply);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.nColormaps);
}
WriteToClient(client, sizeof(rep), &rep);
if (client->swapped)
Swap32Write(client, nummaps * sizeof(Colormap), cm);
else
WriteToClient(client, nummaps * sizeof(Colormap), cm);
free(cm);
return Success; return Success;
} }

View File

@ -310,16 +310,6 @@ SGetFontPathReply(ClientPtr pClient, int size, xGetFontPathReply * pRep)
WriteToClient(pClient, size, pRep); WriteToClient(pClient, size, pRep);
} }
void _X_COLD
SListInstalledColormapsReply(ClientPtr pClient, int size,
xListInstalledColormapsReply * pRep)
{
swaps(&pRep->sequenceNumber);
swapl(&pRep->length);
swaps(&pRep->nColormaps);
WriteToClient(pClient, size, pRep);
}
void _X_COLD void _X_COLD
SAllocColorReply(ClientPtr pClient, int size, xAllocColorReply * pRep) SAllocColorReply(ClientPtr pClient, int size, xAllocColorReply * pRep)
{ {

View File

@ -798,7 +798,7 @@ ReplySwapPtr ReplySwapVector[256] = {
ReplyNotSwappd, /* 80 */ ReplyNotSwappd, /* 80 */
ReplyNotSwappd, ReplyNotSwappd,
ReplyNotSwappd, ReplyNotSwappd,
(ReplySwapPtr) SListInstalledColormapsReply, ReplyNotSwappd,
(ReplySwapPtr) SAllocColorReply, (ReplySwapPtr) SAllocColorReply,
(ReplySwapPtr) SAllocNamedColorReply, /* 85 */ (ReplySwapPtr) SAllocNamedColorReply, /* 85 */
(ReplySwapPtr) SAllocColorCellsReply, (ReplySwapPtr) SAllocColorCellsReply,

View File

@ -68,11 +68,6 @@ extern void SGetFontPathReply(ClientPtr /* pClient */ ,
int /* size */ , int /* size */ ,
xGetFontPathReply * /* pRep */ ); xGetFontPathReply * /* pRep */ );
extern void SListInstalledColormapsReply(ClientPtr /* pClient */ ,
int /* size */ ,
xListInstalledColormapsReply
* /* pRep */ );
extern void SAllocColorReply(ClientPtr /* pClient */ , extern void SAllocColorReply(ClientPtr /* pClient */ ,
int /* size */ , int /* size */ ,
xAllocColorReply * /* pRep */ ); xAllocColorReply * /* pRep */ );