]> git.kaiwu.me - haproxy.git/commit
MINOR: buf: make b_rep_blk() wrapping-proof
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 12 Aug 2026 09:39:54 +0000 (11:39 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 28 Aug 2026 15:26:38 +0000 (17:26 +0200)
commit9addb6729d9cb98faedc23ad6c1a3598ade13a62
tree6347a21c8afc51c6fd9a90b44c125e4d2c4416b5
parent5ce3647dbcfeb9fd552265fbf2499086354578e8
MINOR: buf: make b_rep_blk() wrapping-proof

b_rep_blk() was not versatile because there were a lot of cases
(including wrapping resulting from the insertion or deletion)
that were not supported, this actually made the function not
very useful.

Since there a no more known usages of this API function in the code, but
yet the decompression filters could make use of it in upcoming commits
let's revisit the function by leveraging b_move() to properly support
edge cases such as wrapping.

Now the function is pretty versatile and can safely be used to expand
as well as to shrink buffer when replacing existing data with new data.

There is still one known limitation to this day, <pos> and <end> have
to be contiguous (not interrupted by wrapping buffer), but that could
be improved in the future if needed.

The function assumes the caller already checked that inserted data will
fit in the buffer (removed data also taken into account).
src/buf.c