From b1edd361a0dc41242e08883638059e24d947f6d5 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Fri, 18 Jul 2025 23:38:41 +0200 Subject: [PATCH] dix: rpcbuf: add getter for 4-byte units needed to store buffer contents add x_rpcbuf_wsize_units() to retrieve the amount of data written into the buffer - in 4-byte units. Signed-off-by: Enrico Weigelt, metux IT consult --- dix/rpcbuf_priv.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dix/rpcbuf_priv.h b/dix/rpcbuf_priv.h index e509f5e613..826811790e 100644 --- a/dix/rpcbuf_priv.h +++ b/dix/rpcbuf_priv.h @@ -7,6 +7,7 @@ #include +#include "include/misc.h" #include "include/os.h" /* @@ -216,4 +217,14 @@ Bool x_rpcbuf_write_CARD16s(struct x_rpcbuf *rpcbuf, const CARD16 *values, Bool x_rpcbuf_write_CARD32s(struct x_rpcbuf *rpcbuf, const CARD32 *values, size_t count) _X_ATTRIBUTE_NONNULL_ARG(1); +/* + * retrieve number of 4-byte-units (padded) of data written in the buffer + * + * @param rpcbuf pointer to struct x_rpcbuf to operate on + * @return number of 4-byte units (w/ padding) written into the buffer + */ +static inline size_t x_rpcbuf_wsize_units(struct x_rpcbuf *rpcbuf) { + return bytes_to_int32(pad_to_int32(rpcbuf->wpos)); +} + #endif /* _XSERVER_DIX_RPCBUF_PRIV_H */