]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: htx: add a new function to add a block without filling it
authorWilly Tarreau <w@1wt.eu>
Thu, 3 Jan 2019 17:26:17 +0000 (18:26 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 3 Jan 2019 17:45:38 +0000 (18:45 +0100)
htx_add_blk_type_size() creates a block of a specified type and size
and returns it. The caller can then fill it.

include/common/htx.h
src/htx.c

index 93031cd1fec3dcd4875954354e778b541635414e..3385f148516fbb09a3f60cd84796dabc899fefe9 100644 (file)
@@ -185,6 +185,7 @@ struct htx_blk *htx_replace_header(struct htx *htx, struct htx_blk *blk,
                                   const struct ist name, const struct ist value);
 
 struct htx_blk *htx_add_header(struct htx *htx, const struct ist name, const struct ist value);
+struct htx_blk *htx_add_blk_type_size(struct htx *htx, enum htx_blk_type type, uint32_t blksz);
 struct htx_blk *htx_add_all_headers(struct htx *htx, const struct http_hdr *hdrs);
 struct htx_blk *htx_add_pseudo_header(struct htx *htx,  enum htx_phdr_type phdr, const struct ist value);
 struct htx_blk *htx_add_endof(struct htx *htx, enum htx_blk_type type);
index 83243e060db3922e265cf030c26e55695e0418bf..af94643440902deb2dcb7e59e53c26c5b5c964a4 100644 (file)
--- a/src/htx.c
+++ b/src/htx.c
@@ -661,6 +661,22 @@ struct htx_blk *htx_add_header(struct htx *htx, const struct ist name,
        return blk;
 }
 
+/* Adds an HTX block of type <type> in <htx>, of size <blksz>. It returns the
+ * new block on success. Otherwise, it returns NULL. The caller is responsible
+ * for filling the block itself.
+ */
+struct htx_blk *htx_add_blk_type_size(struct htx *htx, enum htx_blk_type type, uint32_t blksz)
+{
+       struct htx_blk *blk;
+
+       blk = htx_add_blk(htx, type, blksz);
+       if (!blk)
+               return NULL;
+
+       blk->info += blksz;
+       return blk;
+}
+
 struct htx_blk *htx_add_all_headers(struct htx *htx, const struct http_hdr *hdrs)
 {
        int i;