From 4a6425d37374f5f514a67fdb67454b24da64d7ef Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 19 Sep 2017 14:18:46 +0200 Subject: [PATCH] MINOR: buffer: add b_del() to delete a number of characters This will be used by code which directly parses buffers with no channel in the middle (eg: h2, might be used by checks as well). --- include/common/buffer.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/common/buffer.h b/include/common/buffer.h index f1edae054c..8043e29292 100644 --- a/include/common/buffer.h +++ b/include/common/buffer.h @@ -79,6 +79,17 @@ void buffer_slow_realign(struct buffer *buf); __ret; \ }) +/* 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 + * equal to b->i. + */ +static inline void b_del(struct buffer *b, unsigned int del) +{ + b->i -= del; + b->p = b_ptr(b, del); +} + /* Advances the buffer by bytes, which means that the buffer * pointer advances, and that as many bytes from in are transferred * to out. The caller is responsible for ensuring that adv is always