From 2edb06c8bc130885e8b5cb7d47ed853ed32867e9 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 19 Aug 2025 17:58:28 +0200 Subject: [PATCH] dix: rpcbuf: add x_rpcbuf_write_rpcbuf_pad() This is writing the contents of source rpcbuf into the target one, pads it and finally clears the source buffer. Signed-off-by: Enrico Weigelt, metux IT consult --- dix/rpcbuf_priv.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/dix/rpcbuf_priv.h b/dix/rpcbuf_priv.h index 489dee4afb..bd81439ff1 100644 --- a/dix/rpcbuf_priv.h +++ b/dix/rpcbuf_priv.h @@ -291,4 +291,28 @@ static inline void x_rpcbuf_write_counted_string_pad( } } +/* + * write contents of an rpcbuf into another one (padded) and clear the source buffer + * + * @param rpcbuf pointer to the x_rpcbuf_t to operate on + * @param source pointer to source x_rpcbuf_t + */ +static inline void x_rpcbuf_write_rpcbuf_pad( + x_rpcbuf_t *rpcbuf, x_rpcbuf_t *source) +{ + if (!source) + return; + + if (source->error) { + rpcbuf->error = TRUE; + if (rpcbuf->err_clear) { + free(rpcbuf->buffer); + rpcbuf->buffer = NULL; + } + } else { + x_rpcbuf_write_binary_pad(rpcbuf, source->buffer, source->wpos); + } + x_rpcbuf_clear(source); +} + #endif /* _XSERVER_DIX_RPCBUF_PRIV_H */