]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ist: add istissame() function
authorBaptiste Assmann <bedis9@gmail.com>
Sun, 29 Mar 2020 07:10:27 +0000 (09:10 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 5 May 2020 13:28:59 +0000 (15:28 +0200)
The istissame() function takes 2 ist and compare their <.ptr> and <.len>
values respectively. It returns non-zero if they are the same.

include/common/ist.h

index 2b647a22a7b6de44bf636c745660e92a2d478548..8dd6615ed50104e61c0cfe1a88e86fea3b57d720 100644 (file)
@@ -751,6 +751,14 @@ static inline struct ist istadv(const struct ist ist, const size_t nb)
        return ist2(ist.ptr + nb, ist.len - nb);
 }
 
+/*
+ * compare 2 ists and return non-zero if they are the same
+ */
+static inline int istissame(const struct ist ist1, const struct ist ist2)
+{
+       return ((ist1.ptr == ist2.ptr) && (ist1.len == ist2.len));
+}
+
 #ifndef IST_FREESTANDING
 /* This function allocates <size> bytes and returns an `ist` pointing to
  * the allocated area with size `0`.