]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
iovec-util: add iovec_done_many_and_free()
authorLennart Poettering <lennart@poettering.net>
Tue, 11 Nov 2025 10:36:43 +0000 (11:36 +0100)
committerLennart Poettering <lennart@poettering.net>
Sun, 21 Dec 2025 06:04:42 +0000 (07:04 +0100)
src/fundamental/iovec-util-fundamental.h

index fbdd76398d66d1287f0b1458be22154e20357a57..707274f86e53fc6c40115a5d302d9924bc97bf1a 100644 (file)
@@ -31,6 +31,15 @@ static inline void iovec_done(struct iovec *iovec) {
         iovec->iov_len = 0;
 }
 
+static inline void iovec_done_many_and_free(struct iovec *iovec, size_t n) {
+        if (n > 0) {
+                assert(iovec);
+                FOREACH_ARRAY(j, iovec, n)
+                        iovec_done(j);
+        }
+        free(iovec);
+}
+
 static inline bool iovec_is_set(const struct iovec *iovec) {
         /* Checks if the iovec points to a non-empty chunk of memory */
         return iovec && iovec->iov_len > 0 && iovec->iov_base;