MINOR: buffer: provide a new buffer_full() function

This one only focuses on the input part of the buffer and is dedicated
to analysers.
This commit is contained in:
Willy Tarreau 2012-08-27 19:51:36 +02:00 committed by Willy Tarreau
parent ad1cc3df9c
commit 42d06661a2
1 changed files with 14 additions and 0 deletions

View File

@ -156,6 +156,20 @@ static inline int buffer_empty(const struct buffer *buf)
return !buffer_not_empty(buf);
}
/* Returns non-zero if the buffer's INPUT is considered full, which means that
* it holds at least as much INPUT data as (size - reserve). This also means
* that data that are scheduled for output are considered as potential free
* space, and that the reserved space is always considered as not usable. This
* information alone cannot be used as a general purpose free space indicator.
* However it accurately indicates that too many data were fed in the buffer
* for an analyzer for instance. See the channel_full() function for a more
* generic function taking everything into account.
*/
static inline int buffer_full(const struct buffer *b, unsigned int reserve)
{
return (b->i + reserve >= b->size);
}
/* Normalizes a pointer after a subtract */
static inline char *buffer_wrap_sub(const struct buffer *buf, char *ptr)
{