]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: htx: Add helper function to get type and size from the block info field
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 13 Apr 2026 17:04:20 +0000 (19:04 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 14 Apr 2026 12:07:21 +0000 (14:07 +0200)
__htx_blkinfo_type() and __htx_blkinfo_size() function was added to return,
respectively, the type and the size from the block info field. The main
usage for these functions is internal to the htx code.

include/haproxy/htx.h

index 1b720980d01bfcc30e71d4e772eac77d4abc0bc5..972bdaa440efd1f3ccf7e6e74f7f58d6971960f1 100644 (file)
@@ -165,28 +165,38 @@ static inline struct htx_blk *htx_get_blk(const struct htx *htx, uint32_t pos)
        return (struct htx_blk *)(htx->blocks + htx_pos_to_addr(htx, pos));
 }
 
+static inline enum htx_blk_type __htx_blkinfo_type(uint32_t info)
+{
+       return (info >> 28);
+}
+
 /* Returns the type of the block <blk> */
 static inline enum htx_blk_type htx_get_blk_type(const struct htx_blk *blk)
 {
-       return (blk->info >> 28);
+       return __htx_blkinfo_type(blk->info);
 }
 
-/* Returns the size of the block <blk>, depending of its type */
-static inline uint32_t htx_get_blksz(const struct htx_blk *blk)
+static inline enum htx_blk_type __htx_blkinfo_size(uint32_t info)
 {
-       enum htx_blk_type type = htx_get_blk_type(blk);
+       enum htx_blk_type type = __htx_blkinfo_type(info);
 
        switch (type) {
                case HTX_BLK_HDR:
                case HTX_BLK_TLR:
                        /*       name.length       +        value.length        */
-                       return ((blk->info & 0xff) + ((blk->info >> 8) & 0xfffff));
+                       return ((info & 0xff) + ((info >> 8) & 0xfffff));
                default:
                        /*         value.length      */
-                       return (blk->info & 0xfffffff);
+                       return (info & 0xfffffff);
        }
 }
 
+/* Returns the size of the block <blk>, depending of its type */
+static inline uint32_t htx_get_blksz(const struct htx_blk *blk)
+{
+       return __htx_blkinfo_size(blk->info);
+}
+
 /* Returns the position of the oldest entry (head). It returns a signed 32-bits
  * integer, -1 means the HTX message is empty.
  */