`ist_NULL()` returns an `struct ist` with `.ptr = NULL` and `.len = 0`. --- include/common/ist.h | 8 +++++++- src/hpack-dec.c | 4 ++-- src/http.c | 4 ++-- src/http_htx.c | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/include/common/ist.h b/include/common/ist.h index 0d8b45721..4d75d8607 100644 --- a/include/common/ist.h +++ b/include/common/ist.h @@ -183,6 +183,12 @@ static inline struct ist ist2(const void *ptr, size_t len) return (struct ist){ .ptr = (char *)ptr, .len = len }; } +/* returns an `ist` with `.ptr = NULL` and `.len = 0` */ +static inline struct ist ist_NULL() +{ + return ist2(NULL, 0); +} + /* This function MODIFIES the string to add a zero AFTER the end, and returns * the start pointer. The purpose is to use it on strings extracted by parsers * from larger strings cut with delimiters that are not important and can be @@ -705,7 +711,7 @@ static inline struct ist istist(const struct ist ist, const struct ist pat) } return ist2(ret.ptr - 1, ret.len + 1); } - return ist2(NULL, 0); + return ist_NULL(); } /* diff --git a/src/hpack-dec.c b/src/hpack-dec.c index a721fadc4..ab757de29 100644 --- a/src/hpack-dec.c +++ b/src/hpack-dec.c @@ -406,7 +406,7 @@ int hpack_decode_frame(struct hpack_dht *dht, const uint8_t *raw, uint32_t len, value = ist2(vtrash, vlen); } - name = ist2(NULL, 0); + name = ist_NULL(); if (!must_index) name.len = hpack_idx_to_phdr(idx); @@ -458,7 +458,7 @@ int hpack_decode_frame(struct hpack_dht *dht, const uint8_t *raw, uint32_t len, } /* put an end marker */ - list[ret].n = list[ret].v = ist2(NULL, 0); + list[ret].n = list[ret].v = ist_NULL(); ret++; leave: diff --git a/src/http.c b/src/http.c index 75251992a..a122ef732 100644 --- a/src/http.c +++ b/src/http.c @@ -551,7 +551,7 @@ struct ist http_get_authority(const struct ist uri, int no_userinfo) return ist2(start, end - start); not_found: - return ist2(NULL, 0); + return ist_NULL(); } /* Parse the URI from the given transaction (which is assumed to be in request @@ -601,7 +601,7 @@ struct ist http_get_path(const struct ist uri) return ist2(ptr, end - ptr); not_found: - return ist2(NULL, 0); + return ist_NULL(); } /* diff --git a/src/http_htx.c b/src/http_htx.c index 35bb05625..a4829ff81 100644 --- a/src/http_htx.c +++ b/src/http_htx.c @@ -533,7 +533,7 @@ int http_remove_header(struct htx *htx, struct http_hdr_ctx *ctx) blk = htx_remove_blk(htx, blk); if (blk || htx_is_empty(htx)) { ctx->blk = blk; - ctx->value = ist2(NULL, 0); + ctx->value = ist_NULL(); ctx->lws_before = ctx->lws_after = 0; } else { -- 2.25.1