]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
iovec-util: add new iovec_memcmp() helper
authorLennart Poettering <lennart@poettering.net>
Tue, 21 Nov 2023 12:11:45 +0000 (13:11 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 5 Jan 2024 10:10:22 +0000 (11:10 +0100)
src/basic/iovec-util.h

index bbd10e2a676a97bee91e321860dcc70cff83c91b..3b843e2594a6ecbecff1d80294be9ffaf222a0df 100644 (file)
@@ -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);
+}