mirror of
https://github.com/X11Libre/xserver.git
synced 2026-01-26 14:03:17 +00:00
vidmode: ProcVidModeGetAllModeLines(): use x_rpcbuf_t
First step of migration to x_rpcbuf: create a buffer with enough room for the already calculated payload size and pass the raw buffer pointer to our callees as we used to do with the calloc()ed one. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
c10baabc89
commit
c9bd4cc4df
@ -37,6 +37,7 @@ from Kaleb S. KEITHLEY
|
||||
#include <X11/Xproto.h>
|
||||
#include <X11/extensions/xf86vmproto.h>
|
||||
|
||||
#include "dix/rpcbuf_priv.h"
|
||||
#include "os/log_priv.h"
|
||||
|
||||
#include "misc.h"
|
||||
@ -425,11 +426,11 @@ ProcVidModeGetAllModeLines(ClientPtr client)
|
||||
swapl(&rep.modecount);
|
||||
}
|
||||
|
||||
char *payload = calloc(1, payload_len);
|
||||
if (!payload)
|
||||
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
|
||||
if (!x_rpcbuf_makeroom(&rpcbuf, payload_len))
|
||||
return BadAlloc;
|
||||
|
||||
char *walk = payload;
|
||||
char *walk = rpcbuf.buffer;
|
||||
|
||||
do {
|
||||
walk = (ver < 2) ? fillModeInfoV1(client, walk, dotClock, mode)
|
||||
@ -437,8 +438,8 @@ ProcVidModeGetAllModeLines(ClientPtr client)
|
||||
} while (pVidMode->GetNextModeline(pScreen, &mode, &dotClock));
|
||||
|
||||
WriteToClient(client, sizeof(xXF86VidModeGetAllModeLinesReply), &rep);
|
||||
WriteToClient(client, payload_len, payload);
|
||||
free(payload);
|
||||
WriteToClient(client, payload_len, rpcbuf.buffer);
|
||||
x_rpcbuf_clear(&rpcbuf);
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user