From: Willy Tarreau Date: Tue, 27 Feb 2024 08:12:19 +0000 (+0100) Subject: MINOR: ring: add ring_data() to report the amount of data in a ring X-Git-Tag: v3.0-dev6~43 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4c41fcd0dacd60a9c225378e147f204c7f79f815;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/include/haproxy/ring.h b/include/haproxy/ring.h index 0e8a3bf860..ddcc558c0a 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 */ /*