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

index abfa8c07dab8e2348c2151b887bdc33031f2744f..bc7a67054adae996a3a17bbad483f3bd3c53f199 100644 (file)
@@ -29,6 +29,12 @@ static inline struct iovec* iovec_make_string(struct iovec *iovec, const char *s
 #define IOVEC_MAKE_STRING(s) \
         *iovec_make_string(&(struct iovec) {}, s)
 
+#define CONST_IOVEC_MAKE_STRING(s)              \
+        (const struct iovec) {                  \
+                .iov_base = (char*) s,          \
+                .iov_len = STRLEN(s),           \
+        }
+
 static inline void iovec_done(struct iovec *iovec) {
         /* A _cleanup_() helper that frees the iov_base in the iovec */
         assert(iovec);