diff --git a/src/fundamental/iovec-util-fundamental.h b/src/fundamental/iovec-util-fundamental.h index fbdd76398d..707274f86e 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;