From: Olivier Houchard Date: Thu, 28 Jun 2018 17:17:38 +0000 (+0200) Subject: MINOR: buffer: Introduce b_sub(), b_add(), and bo_add() X-Git-Tag: v1.9-dev1~163 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=09138ecc49ceafa51194ea9fab1ceccfbb7249c3;p=thirdparty%2Fhaproxy.git MINOR: buffer: Introduce b_sub(), b_add(), and bo_add() 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. --- diff --git a/include/common/buf.h b/include/common/buf.h index 5e7f3b74ad..294deb7945 100644 --- a/include/common/buf.h +++ b/include/common/buf.h @@ -291,6 +291,26 @@ static inline void b_reset(struct buffer *b) b->p = b_orig(b); } +/* b_sub() : decreases the buffer length by */ +static inline void b_sub(struct buffer *b, size_t count) +{ + b->i -= count; +} + +/* b_add() : increase the buffer length by */ +static inline void b_add(struct buffer *b, size_t count) +{ + b->i += count; +} + +/* bo_add() : increase the buffer output and length by + * (LEGACY API) + */ +static inline void bo_add(struct buffer *b, size_t count) +{ + b->o += count; +} + #endif /* _COMMON_BUF_H */