]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: buffer: Introduce b_sub(), b_add(), and bo_add()
authorOlivier Houchard <ohouchard@haproxy.com>
Thu, 28 Jun 2018 17:17:38 +0000 (19:17 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 19 Jul 2018 14:23:39 +0000 (16:23 +0200)
Instead of doing b->i -= directly, introduce b_sub(), that does the job, to
make it easier to switch to the future API.

Also add b_add(), that increases b->i, instead of using it directly, and
bo_add(), that does increase b->o.

include/common/buf.h

index 5e7f3b74adf951a06ac7b2918ea9c9c4c16bf54b..294deb79454b9236b6f1875f914979a463cd4f96 100644 (file)
@@ -291,6 +291,26 @@ static inline void b_reset(struct buffer *b)
        b->p = b_orig(b);
 }
 
+/* b_sub() : decreases the buffer length by <count> */
+static inline void b_sub(struct buffer *b, size_t count)
+{
+       b->i -= count;
+}
+
+/* b_add() : increase the buffer length by <count> */
+static inline void b_add(struct buffer *b, size_t count)
+{
+       b->i += count;
+}
+
+/* bo_add() : increase the buffer output and length by <count>
+ * (LEGACY API)
+ */
+static inline void bo_add(struct buffer *b, size_t count)
+{
+       b->o += count;
+}
+
 
 #endif /* _COMMON_BUF_H */