]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: buffer: add b_del() to delete a number of characters
authorWilly Tarreau <w@1wt.eu>
Tue, 19 Sep 2017 12:18:46 +0000 (14:18 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 20 Sep 2017 09:27:31 +0000 (11:27 +0200)
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

index f1edae054c0f2a95f0e068a7fd26b4f3d18ecaca..8043e29292c67948f8ce271b014ca2e40d13a3cb 100644 (file)
@@ -79,6 +79,17 @@ void buffer_slow_realign(struct buffer *buf);
                __ret;                                          \
        })
 
+/* Skips <del> bytes in a one-way buffer <b> : <p> advances by <del>, <i>
+ * shrinks by <del> as well, and <o> is left untouched (supposed to be zero).
+ * The caller is responsible for ensuring that <del> 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 <adv> 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