]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util: adds util function SCBufferCmp
authorPhilippe Antoine <contact@catenacyber.fr>
Tue, 18 Feb 2020 14:01:03 +0000 (15:01 +0100)
committerPhilippe Antoine <contact@catenacyber.fr>
Fri, 24 Sep 2021 13:22:09 +0000 (15:22 +0200)
Compares two buffers with their two sizes

src/util-memcmp.h

index f1e1fdd63b498cbc172297d27726f0dc013e1785..61eeca053e59ed6706bd475ce91adf6d822c4fe6 100644 (file)
@@ -377,5 +377,15 @@ static inline int SCMemcmpLowercase(const void *s1, const void *s2, size_t len)
 
 #endif /* SIMD */
 
+static inline int SCBufferCmp(const void *s1, size_t len1, const void *s2, size_t len2)
+{
+    if (len1 == len2) {
+        return SCMemcmp(s1, s2, len1);
+    } else if (len1 < len2) {
+        return -1;
+    }
+    return 1;
+}
+
 #endif /* __UTIL_MEMCMP_H__ */