From: Christopher Faulet Date: Tue, 21 Sep 2021 13:45:05 +0000 (+0200) Subject: MINOR: htx: Add a function to know if the free space wraps X-Git-Tag: v2.5-dev8~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=361fbcc14acc4a3bed9161934f2524db8ac2069e;p=thirdparty%2Fhaproxy.git MINOR: htx: Add a function to know if the free space wraps the htx_space_wraps() function may now be used to know if the free space of an HTX message wraps. It does the same as b_space_wraps(). --- diff --git a/include/haproxy/htx.h b/include/haproxy/htx.h index 0faf296467..c7ae308913 100644 --- a/include/haproxy/htx.h +++ b/include/haproxy/htx.h @@ -606,6 +606,17 @@ static inline uint32_t htx_free_data_space(const struct htx *htx) return (free - sizeof(struct htx_blk)); } +/* Returns non-zero only if the HTX message free space wraps */ +static inline int htx_space_wraps(const struct htx *htx) +{ + uint32_t headroom, tailroom; + + headroom = (htx->end_addr - htx->head_addr); + tailroom = (htx_pos_to_addr(htx, htx->tail) - htx->tail_addr); + + return (headroom && tailroom); +} + /* Returns the maximum size for a block, not exceeding bytes. may be * set to -1 to have no limit. */