MINOR: buffer: Add b_set_data().

Add a new function that lets you set the amount of input in a buffer.
For now it extends/truncates b->i except if the total length is
below b->o in which case it clears i and adjusts o.
This commit is contained in:
Olivier Houchard 2018-06-28 19:10:25 +02:00 committed by Willy Tarreau
parent 09138ecc49
commit a04e40d578
1 changed files with 11 additions and 0 deletions

View File

@ -311,6 +311,17 @@ static inline void bo_add(struct buffer *b, size_t count)
b->o += count; b->o += count;
} }
/* b_set_data() : sets the buffer's length */
static inline void b_set_data(struct buffer *b, size_t len)
{
if (len >= b->o)
b->i = len - b->o;
else {
b->o = len;
b->i = 0;
}
}
#endif /* _COMMON_BUF_H */ #endif /* _COMMON_BUF_H */