From 4c41fcd0dacd60a9c225378e147f204c7f79f815 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 27 Feb 2024 09:12:19 +0100 Subject: [PATCH] MINOR: ring: add ring_data() to report the amount of data in a ring This will be used as an accessor for the few functions that need this outside of ring.c. --- include/haproxy/ring.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/haproxy/ring.h b/include/haproxy/ring.h index 0e8a3bf..ddcc558 100644 --- a/include/haproxy/ring.h +++ b/include/haproxy/ring.h @@ -45,6 +45,12 @@ size_t ring_max_payload(const struct ring *ring); int ring_dispatch_messages(struct ring *ring, void *ctx, size_t *ofs_ptr, size_t *last_ofs_ptr, uint flags, ssize_t (*msg_handler)(void *ctx, const struct buffer *buf, size_t ofs, size_t len)); +/* returns the number of bytes in the ring */ +static inline size_t ring_data(const struct ring *ring) +{ + return b_data(&ring->buf); +} + #endif /* _HAPROXY_RING_H */ /* -- 1.7.10.4