MINOR: buffer: merge b{i,o}_contig_space()
These ones were merged into a single b_contig_space() that covers both
(the bo_ case was a simplified version of the other one). The function
doesn't use ->i nor ->o anymore.
diff --git a/include/common/buf.h b/include/common/buf.h
index 0ee9c54..33830f7 100644
--- a/include/common/buf.h
+++ b/include/common/buf.h
@@ -293,6 +293,24 @@
return data;
}
+/* b_contig_space() : returns the amount of bytes that can be appended to the
+ * buffer at once.
+ */
+static inline size_t b_contig_space(const struct buffer *b)
+{
+ const char *left, *right;
+
+ right = b_head(b);
+ left = right + b_data(b);
+
+ if (left >= b_wrap(b))
+ left -= b_size(b);
+ else
+ right = b_wrap(b);
+
+ return right - left;
+}
+
/*********************************************/
/* Functions used to modify the buffer state */
diff --git a/include/common/buffer.h b/include/common/buffer.h
index 8638bd6..10ff640 100644
--- a/include/common/buffer.h
+++ b/include/common/buffer.h
@@ -105,46 +105,6 @@
b->o -= del;
}
-/* Return the amount of bytes that can be written into the input area at once
- * including reserved space which may be overwritten (this is the caller
- * responsibility to know if the reserved space is protected or not).
-*/
-static inline int bi_contig_space(const struct buffer *b)
-{
- const char *left, *right;
-
- left = b->p + b->i;
- right = b->p - b->o;
- if (left >= b->data + b->size)
- left -= b->size;
- else {
- if (right < b->data)
- right += b->size;
- else
- right = b->data + b->size;
- }
- return (right - left);
-}
-
-/* Return the amount of bytes that can be written into the output area at once
- * including reserved space which may be overwritten (this is the caller
- * responsibility to know if the reserved space is protected or not). Input data
- * are assumed to not exist.
-*/
-static inline int bo_contig_space(const struct buffer *b)
-{
- const char *left, *right;
-
- left = b->p;
- right = b->p - b->o;
- if (right < b->data)
- right += b->size;
- else
- right = b->data + b->size;
-
- return (right - left);
-}
-
/* Return the buffer's length in bytes by summing the input and the output */
static inline int buffer_len(const struct buffer *buf)
{
@@ -334,7 +294,7 @@
if (!len)
return 0;
- half = bo_contig_space(b);
+ half = b_contig_space(b);
if (half > len)
half = len;
@@ -444,7 +404,7 @@
if (!len)
return 0;
- half = bi_contig_space(b);
+ half = b_contig_space(b);
if (half > len)
half = len;