]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: buffers: split b_force_xfer() into b_cpy() and b_force_xfer()
authorWilliam Lallemand <wlallemand@haproxy.org>
Mon, 10 Oct 2022 15:27:47 +0000 (17:27 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Thu, 13 Oct 2022 14:45:28 +0000 (16:45 +0200)
Split the b_force_xfer() into b_ncat() and b_force_xfer().

The previous b_force_xfer() implementation was basically a copy with a
b_del on the src buffer. Keep this implementation to make b_ncat(), and
just call b_ncat() + b_del() into b_force_xfer().

include/haproxy/buf.h

index 4ea4b73f13f1548f5a1c2cd31eef1b71379bee5a..f2f003c15d10fb706ef46a6ffcbd65d21f11b5bc 100644 (file)
@@ -614,11 +614,12 @@ static inline size_t b_xfer(struct buffer *dst, struct buffer *src, size_t count
        return ret;
 }
 
-/* b_force_xfer() : same as b_xfer() but without zero copy.
- * The caller is responsible for ensuring that <count> is not
- * larger than b_room(dst).
+/* b_ncat() : Copy <count> from <src> buffer at the end of <dst> buffer.
+ * The caller is  responsible for  ensuring that <count> is not larger than
+ * b_room(dst).
+ * Returns the number of bytes copied.
  */
-static inline size_t b_force_xfer(struct buffer *dst, struct buffer *src, size_t count)
+static inline size_t b_ncat(struct buffer *dst, struct buffer *src, size_t count)
 {
        size_t ret, block1, block2;
 
@@ -643,10 +644,25 @@ static inline size_t b_force_xfer(struct buffer *dst, struct buffer *src, size_t
        if (block2)
                __b_putblk(dst, b_peek(src, block1), block2);
 
-       b_del(src, ret);
  leave:
        return ret;
 }
+
+/* b_force_xfer() : same as b_xfer() but without zero copy.
+ * The caller is responsible for ensuring that <count> is not
+ * larger than b_room(dst).
+ */
+static inline size_t b_force_xfer(struct buffer *dst, struct buffer *src, size_t count)
+{
+       size_t ret;
+
+       ret = b_ncat(dst, src, count);
+       b_del(src, ret);
+
+       return ret;
+}
+
+
 /* Moves <len> bytes from absolute position <src> of buffer <b> by <shift>
  * bytes, while supporting wrapping of both the source and the destination.
  * The position is relative to the buffer's origin and may overlap with the