From: Lennart Poettering Date: Tue, 21 Nov 2023 12:11:45 +0000 (+0100) Subject: iovec-util: add new iovec_memcmp() helper X-Git-Tag: v256-rc1~1263^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bf38e4c0c1ecf2e21435e97d1c074a407c46917c;p=thirdparty%2Fsystemd.git iovec-util: add new iovec_memcmp() helper --- diff --git a/src/basic/iovec-util.h b/src/basic/iovec-util.h index bbd10e2a676..3b843e2594a 100644 --- a/src/basic/iovec-util.h +++ b/src/basic/iovec-util.h @@ -58,3 +58,14 @@ char* set_iovec_string_field(struct iovec *iovec, size_t *n_iovec, const char *f char* set_iovec_string_field_free(struct iovec *iovec, size_t *n_iovec, const char *field, char *value); void iovec_array_free(struct iovec *iovec, size_t n_iovec); + +static inline int iovec_memcmp(const struct iovec *a, const struct iovec *b) { + + if (a == b) + return 0; + + return memcmp_nn(a ? a->iov_base : NULL, + a ? a->iov_len : 0, + b ? b->iov_base : NULL, + b ? b->iov_len : 0); +}