]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: htx: Add an helper function to get the max space usable for a block
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 7 Jan 2019 12:48:55 +0000 (13:48 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 7 Jan 2019 15:32:02 +0000 (16:32 +0100)
This patch must be backported in 1.9 because it will be used by a futher patch
to fix a bug.

include/common/htx.h

index 3385f148516fbb09a3f60cd84796dabc899fefe9..56a6c9b969e8f1c10e9236bee94c2cb43f68fde8 100644 (file)
@@ -633,6 +633,15 @@ static inline uint32_t htx_free_space(const struct htx *htx)
        return (htx->size - htx_used_space(htx));
 }
 
+/* Returns the maximum space usable for data in <htx>. This is in fact the
+ * maximum sice for a uniq block to fill the HTX message. */
+static inline uint32_t htx_max_data_space(const struct htx *htx)
+{
+       if (!htx->size)
+               return 0;
+       return (htx->size - sizeof(htx->blocks[0]));
+}
+
 /* Returns the maximum size available to store some data in <htx> if a new block
  * is reserved.
  */