From: Philippe Antoine Date: Tue, 18 Feb 2020 14:01:03 +0000 (+0100) Subject: util: adds util function SCBufferCmp X-Git-Tag: suricata-7.0.0-beta1~1367 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0012f97b272a0f76fa092a96740ffa3bd444a60;p=thirdparty%2Fsuricata.git util: adds util function SCBufferCmp Compares two buffers with their two sizes --- diff --git a/src/util-memcmp.h b/src/util-memcmp.h index f1e1fdd63b..61eeca053e 100644 --- a/src/util-memcmp.h +++ b/src/util-memcmp.h @@ -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__ */