MINOR: buffer: introduce b_realign_if_empty()

Many places deal with buffer realignment after data removal. The method
is always the same : if the buffer is empty, set its pointer to the origin.
Let's have a function for this so that we have less code to change with the
new API.
This commit is contained in:
Willy Tarreau 2018-06-15 17:50:15 +02:00
parent a04e40d578
commit f17f19f1a7
1 changed files with 7 additions and 0 deletions

View File

@ -322,6 +322,13 @@ static inline void b_set_data(struct buffer *b, size_t len)
}
}
/* b_realign_if_empty() : realigns a buffer if it's empty */
static inline void b_realign_if_empty(struct buffer *b)
{
if (!b_data(b))
b->p = b->data;
}
#endif /* _COMMON_BUF_H */