Xext: vidmode: ProcVidModeGetMonitor(): move local buffers on stack

No need to go through global heap here, for such short-lived and
small buffers. And stack variables are automatically cleaned up
on leave.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2024-07-12 19:30:45 +02:00
committed by Enrico Weigelt, metux IT consult .
parent f8d240b56b
commit fc37435fda

View File

@@ -1200,7 +1200,6 @@ static int
ProcVidModeGetMonitor(ClientPtr client)
{
REQUEST(xXF86VidModeGetMonitorReq);
CARD32 *hsyncdata, *vsyncdata;
ScreenPtr pScreen;
VidModePtr pVidMode;
int i, nHsync, nVrefresh, vendorLength = 0, modelLength = 0;
@@ -1244,16 +1243,8 @@ ProcVidModeGetMonitor(ClientPtr client)
pad_to_int32(modelLength)),
};
hsyncdata = xallocarray(nHsync, sizeof(CARD32));
if (!hsyncdata) {
return BadAlloc;
}
vsyncdata = xallocarray(nVrefresh, sizeof(CARD32));
if (!vsyncdata) {
free(hsyncdata);
return BadAlloc;
}
CARD32 hsyncdata[nHsync];
CARD32 vsyncdata[nVrefresh];
for (i = 0; i < nHsync; i++) {
hsyncdata[i] = (unsigned short) (pVidMode->GetMonitorValue(pScreen,
@@ -1287,9 +1278,6 @@ ProcVidModeGetMonitor(ClientPtr client)
WriteToClient(client, rep.modelLength,
(pVidMode->GetMonitorValue(pScreen, VIDMODE_MON_MODEL, 0)).ptr);
free(hsyncdata);
free(vsyncdata);
return Success;
}