From: Willy Tarreau Date: Tue, 19 Sep 2017 19:14:08 +0000 (+0200) Subject: MINOR: buffer: add b_end() and b_to_end() X-Git-Tag: v1.8-dev3~79 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=26488ad358ab7c6d8cd801b3c63fa4cf87cedf8e;p=thirdparty%2Fhaproxy.git MINOR: buffer: add b_end() and b_to_end() These ones return respectively the pointer to the end of the buffer and the distance between b->p and the end. These will simplify a bit some new code needed to parse directly from a wrapping buffer. --- diff --git a/include/common/buffer.h b/include/common/buffer.h index 8043e29292..b29946673e 100644 --- a/include/common/buffer.h +++ b/include/common/buffer.h @@ -79,6 +79,18 @@ void buffer_slow_realign(struct buffer *buf); __ret; \ }) +/* Returns the pointer to the buffer's end (data+size) */ +static inline const char *b_end(const struct buffer *b) +{ + return b->data + b->size; +} + +/* Returns the distance between

and the buffer's end (data+size) */ +static inline unsigned int b_to_end(const struct buffer *b) +{ + return b->data + b->size - b->p; +} + /* Skips bytes in a one-way buffer :

advances by , * shrinks by as well, and is left untouched (supposed to be zero). * The caller is responsible for ensuring that is always smaller than or