From 9e46496d45ff06317ae8f4f785e6117e5b786f6f Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 17 Oct 2019 10:38:10 +0200 Subject: [PATCH] MINOR: istbuf: add b_fromist() to make a buffer from an ist A lot of our chunk-based functions are able to work on a buffer pointer but not on an ist. Instead of duplicating all of them to also take an ist as a source, let's have a macro to make a temporary dummy buffer from an ist. This will only result in structure field manipulations that the compiler will quickly figure to eliminate them with inline functions, and in other cases it will just use 4 words in the stack before calling a function, instead of performing intermediary conversions. --- include/common/istbuf.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/common/istbuf.h b/include/common/istbuf.h index 9b6ce7c6b..933ec99fb 100644 --- a/include/common/istbuf.h +++ b/include/common/istbuf.h @@ -33,6 +33,9 @@ #include +/* makes a buffer pointer from an IST */ +#define b_fromist(in) ({ const struct ist __i = (in); &(const struct buffer){ .area = __i.ptr, .head = 0, .data = __i.len, .size = __i.len}; }) + /* b_isteq() : returns > 0 if the first characters of buffer starting * at offset relative to the buffer's head match . (empty strings do * match). It is designed to be used with reasonably small strings (it matches