From: Lennart Poettering Date: Tue, 11 Nov 2025 10:36:43 +0000 (+0100) Subject: iovec-util: add iovec_done_many_and_free() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e3bdf90d9322a81faa7a0d4c168dee4bf3d6ef2;p=thirdparty%2Fsystemd.git iovec-util: add iovec_done_many_and_free() --- diff --git a/src/fundamental/iovec-util-fundamental.h b/src/fundamental/iovec-util-fundamental.h index fbdd76398d6..707274f86e5 100644 --- a/src/fundamental/iovec-util-fundamental.h +++ b/src/fundamental/iovec-util-fundamental.h @@ -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;