haproxy/include/haproxy/ncbmbuf-t.h
Amaury Denoyelle b9f91ad3ff MINOR: ncbmbuf: define new ncbmbuf type
Define ncbmbuf which is an alternative non-contiguous buffer
implementation. "bm" abbreviation stands for bitmap, which reflects how
gaps and filled blocks are encoded. The main purpose of this
implementation is to get rid of the ncbuf limitation regarding the
minimal size for gaps between two blocks of data.

This commit adds the new module ncbmbuf. Along with it, some utility
functions such as ncbmb_make(), ncbmb_init() and ncbmb_is_empty() are
defined. Public API of ncbmbuf will be extended in the following
patches.

This patch is not considered a bug fix. However, it will be required to
fix issue encountered on QUIC CRYPTO frames parsing. Thus, it will be
necessary to backport the current patch prior to the fix to come.
2025-10-22 15:04:06 +02:00

32 lines
1 KiB
C

#ifndef _HAPROXY_NCBMBUF_T_H
#define _HAPROXY_NCBMBUF_T_H
#include <haproxy/ncbuf_common-t.h>
/* Non-contiguous bitmap buffer
*
* This module is an alternative implementation to ncbuf type. Its main
* difference is that filled blocks and gaps are encoded via a bitmap.
*
* The main advantage of the bitmap is that contrary to ncbuf type there is no
* limitation on the minimal size of gaps. Thus, operation such as add and
* advance are guaranteed to succeed.
*
* Storage is reserved for the bitmap at the end of the buffer area,
* representing roughly 1/9 of the total space. Thus, usable buffer storage is
* smaller than the default ncbuf type.
*/
#define NCBMBUF_NULL ((struct ncbmbuf){ })
struct ncbmbuf {
char *area; /* allocated area used for both data and bitmap storage */
unsigned char *bitmap; /* bitmap storage located at the end of allocated area */
ncb_sz_t size; /* size usable for data storage */
ncb_sz_t size_bm; /* size of bitmap storage */
ncb_sz_t head;
};
#endif /* _HAPROXY_NCBMBUF_T_H */