]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: ncbuf: define non-contiguous buffer
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 9 May 2022 07:37:27 +0000 (09:37 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 12 May 2022 16:13:21 +0000 (18:13 +0200)
commit1b5f77fc181b5c59351f5f6e474317505e4c5a8f
tree35439d300cddc9a4eeefcde84a92eb8464c06913
parent31fe308accd5949e9d0d94dfbbd471be2b3a1c08
MINOR: ncbuf: define non-contiguous buffer

Define the new type ncbuf. It can be used as a buffer with
non-contiguous data and wrapping support.

To reduce as much as possible the memory footprint, size of data and
gaps are stored in the gaps themselves. This put some limitation on the
buffer usage. A reserved space is present just before the head to store
the size of the first data block. Also, add and delete operations will
be constrained to ensure minimal gap sizes are preserved.

The sizes stored in the gaps are represented by a custom type named
ncb_sz_t. This type is a typedef to easily change it : this has a
direct impact on the maximum buffer size (MAX(ncb_sz_t) - sizeof(ncb_sz_t))
and the minimal gap sizes (sizeof(ncb_sz_t) * 2)).
Currently, it is set to uint32_t.
Makefile
include/haproxy/ncbuf-t.h [new file with mode: 0644]
include/haproxy/ncbuf.h [new file with mode: 0644]
src/ncbuf.c [new file with mode: 0644]