From: Christopher Faulet Date: Tue, 10 Mar 2026 07:09:12 +0000 (+0100) Subject: MINOR: dynbuf: Add helper functions to alloc large and small buffers X-Git-Tag: v3.4-dev8~136 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8c96bf9cbaea5d5a955e431568e68783b204355;p=thirdparty%2Fhaproxy.git MINOR: dynbuf: Add helper functions to alloc large and small buffers b_alloc_small() and b_alloc_large() can now be used to alloc small or larger buffers. For now, unlike default buffers, buffer_wait lists are not used. --- diff --git a/include/haproxy/dynbuf.h b/include/haproxy/dynbuf.h index d487e1068..c8d7a5bcd 100644 --- a/include/haproxy/dynbuf.h +++ b/include/haproxy/dynbuf.h @@ -200,6 +200,35 @@ static inline char *__b_get_emergency_buf(void) __b_free((_buf)); \ } while (0) + +static inline struct buffer *b_alloc_small(struct buffer *buf) +{ + char *area = NULL; + + if (!buf->size) { + area = pool_alloc(pool_head_small_buffer); + if (!area) + return NULL; + buf->area = area; + buf->size = global.tune.bufsize_small; + } + return buf; +} + +static inline struct buffer *b_alloc_large(struct buffer *buf) +{ + char *area = NULL; + + if (!buf->size) { + area = pool_alloc(pool_head_large_buffer); + if (!area) + return NULL; + buf->area = area; + buf->size = global.tune.bufsize_large; + } + return buf; +} + /* Offer one or multiple buffer currently belonging to target to whoever * needs one. Any pointer is valid for , including NULL. Its purpose is * to avoid passing a buffer to oneself in case of failed allocations (e.g.