]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ist: Add `istappend(struct ist, char)`
authorTim Duesterhus <tim@bastelstu.be>
Mon, 5 Apr 2021 15:53:54 +0000 (17:53 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Apr 2021 17:50:43 +0000 (19:50 +0200)
This function appends the given char to the given `ist` and returns
the resulting `ist`.

include/import/ist.h

index 1262e8f5991ce38fad4b140b0b3ac43a55776ae2..3f63ed2dda114a92d3beef94371035675b090db0 100644 (file)
@@ -407,6 +407,16 @@ static inline int istneq(const struct ist ist1, const struct ist ist2, size_t co
        return isteq(l, r);
 }
 
+/* appends <src> after <dst>. The caller must ensure that the underlying buffer
+ * is large enough to fit the character.
+ */
+static inline struct ist istappend(struct ist dst, const char src)
+{
+       dst.ptr[dst.len++] = src;
+
+       return dst;
+}
+
 /* copies <src> over <dst> for a maximum of <count> bytes. Returns the number
  * of characters copied (src.len), or -1 if it does not fit. In all cases, the
  * contents are copied prior to reporting an error, so that the destination