summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-02-23 11:42:11 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-02-23 15:09:59 +0900
commit253a83ea44c4a45ff6b362ba17bd58964b183d17 (patch)
treeb348760be778382335bde01b2e2785971a87303b
parentdcef5e293f409a73c2e49f0b6f3c4ecd60df7618 (diff)
downloadsystemd-253a83ea44c4a45ff6b362ba17bd58964b183d17.tar.gz
io-util: introduce iovec_array_free()
It will be used in later commits.
-rw-r--r--src/basic/io-util.c10
-rw-r--r--src/basic/io-util.h2
2 files changed, 12 insertions, 0 deletions
diff --git a/src/basic/io-util.c b/src/basic/io-util.c
index f642beca3a..6f6fb8068c 100644
--- a/src/basic/io-util.c
+++ b/src/basic/io-util.c
@@ -362,3 +362,13 @@ size_t iovw_size(struct iovec_wrapper *iovw) {
return n;
}
+
+void iovec_array_free(struct iovec *iov, size_t n) {
+ if (!iov)
+ return;
+
+ for (size_t i = 0; i < n; i++)
+ free(iov[i].iov_base);
+
+ free(iov);
+}
diff --git a/src/basic/io-util.h b/src/basic/io-util.h
index 3afb134266..e7e78e9121 100644
--- a/src/basic/io-util.h
+++ b/src/basic/io-util.h
@@ -105,3 +105,5 @@ int iovw_put_string_field(struct iovec_wrapper *iovw, const char *field, const c
int iovw_put_string_field_free(struct iovec_wrapper *iovw, const char *field, char *value);
void iovw_rebase(struct iovec_wrapper *iovw, char *old, char *new);
size_t iovw_size(struct iovec_wrapper *iovw);
+
+void iovec_array_free(struct iovec *iov, size_t n);