]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: buffer: rename the data length member to '->data'
authorWilly Tarreau <w@1wt.eu>
Tue, 10 Jul 2018 08:43:27 +0000 (10:43 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 19 Jul 2018 14:23:43 +0000 (16:23 +0200)
It used to be called 'len' during the reorganisation but strictly speaking
it's not a length since it wraps. Also we already use '_data' as the suffix
to count available data, and data is also what we use to indicate the amount
of data in a pipe so let's improve consistency here. It was important to do
this in two operations because data used to be the name of the pointer to
the storage area.

include/common/buf.h
include/common/istbuf.h
include/proto/channel.h

index b0b4e64e1556cb6877a2ab6815d9d04e5715953e..bd58a4d9d891165bb50cf44961bb742969fa2189 100644 (file)
@@ -33,7 +33,7 @@
 /* Structure defining a buffer's head */
 struct buffer {
        size_t head;                /* start offset of remaining data relative to area */
-       size_t len;                 /* length of data after head */
+       size_t data;                /* amount of data after head including wrapping */
        size_t size;                /* buffer size in bytes */
        char   area[0];             /* <size> bytes of stored data */
 };
@@ -72,7 +72,7 @@ static inline char *b_wrap(const struct buffer *b)
 /* b_data() : returns the number of bytes present in the buffer. */
 static inline size_t b_data(const struct buffer *b)
 {
-       return b->len;
+       return b->data;
 }
 
 /* b_room() : returns the amount of room left in the buffer */
@@ -94,7 +94,7 @@ static inline size_t b_full(const struct buffer *b)
  */
 static inline size_t __b_stop_ofs(const struct buffer *b)
 {
-       return b->head + b->len;
+       return b->head + b->data;
 }
 
 static inline const char *__b_stop(const struct buffer *b)
@@ -365,25 +365,25 @@ static inline size_t b_getblk_nc(const struct buffer *buf, const char **blk1, si
 static inline void b_reset(struct buffer *b)
 {
        b->head = 0;
-       b->len  = 0;
+       b->data = 0;
 }
 
 /* b_sub() : decreases the buffer length by <count> */
 static inline void b_sub(struct buffer *b, size_t count)
 {
-       b->len -= count;
+       b->data -= count;
 }
 
 /* b_add() : increase the buffer length by <count> */
 static inline void b_add(struct buffer *b, size_t count)
 {
-       b->len += count;
+       b->data += count;
 }
 
 /* b_set_data() : sets the buffer's length */
 static inline void b_set_data(struct buffer *b, size_t len)
 {
-       b->len = len;
+       b->data = len;
 }
 
 /* b_del() : skips <del> bytes in a buffer <b>. Covers both the output and the
@@ -392,7 +392,7 @@ static inline void b_set_data(struct buffer *b, size_t len)
  */
 static inline void b_del(struct buffer *b, size_t del)
 {
-       b->len  -= del;
+       b->data -= del;
        b->head += del;
        if (b->head >= b->size)
                b->head -= b->size;
@@ -455,7 +455,7 @@ static inline void b_putchr(struct buffer *b, char c)
        if (b_full(b))
                return;
        *b_tail(b) = c;
-       b->len++;
+       b->data++;
 }
 
 /* b_putblk() : tries to append block <blk> at the end of buffer <b>. Supports
@@ -476,10 +476,10 @@ static inline size_t b_putblk(struct buffer *b, const char *blk, size_t len)
                half = len;
 
        memcpy(b_tail(b), blk, half);
-       b->len += half;
+       b->data += half;
        if (len > half) {
                memcpy(b_tail(b), blk + half, len - half);
-               b->len += len - half;
+               b->data += len - half;
        }
        return len;
 }
index 2210d4a66e77676c2fc1ab94fea72bea6c200539..7631212cf6c30b9b86b33863a566537440cebe40 100644 (file)
@@ -98,7 +98,7 @@ static inline ssize_t b_istput(struct buffer *b, const struct ist ist)
                return r.len < b->size ? 0 : -1;
 
        p = b_tail(b);
-       b->len += r.len;
+       b->data += r.len;
        while (r.len--) {
                *p++ = *r.ptr++;
                if (unlikely(p == end))
index 26ac619511511b6c7bd28408e7f034e372b7ec43..27023ab6c5d57793d8cb3b9bd0b6006697fcd031 100644 (file)
@@ -193,7 +193,7 @@ static inline void c_realign_if_empty(struct channel *chn)
 /* Sets the amount of output for the channel */
 static inline void co_set_data(struct channel *c, size_t output)
 {
-       c->buf->len += output - c->output;
+       c->buf->data += output - c->output;
        c->output = output;
 }
 
@@ -745,7 +745,7 @@ static inline void channel_truncate(struct channel *chn)
        if (!ci_data(chn))
                return;
 
-       chn->buf->len = co_data(chn);
+       chn->buf->data = co_data(chn);
 }
 
 /* This function realigns a possibly wrapping channel buffer so that the input