iovec-util: add iovec_is_valid() helper

This commit is contained in:
Lennart Poettering
2024-01-05 11:10:22 +01:00
parent 33d1febbd7
commit 39f586873d
+6
View File
@@ -45,9 +45,15 @@ static inline void iovec_done_erase(struct iovec *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;
}
static inline bool iovec_is_valid(const struct iovec *iovec) {
/* Checks if the iovec is either NULL, empty or points to a valid bit of memory */
return !iovec || (iovec->iov_base || iovec->iov_len == 0);
}
char* set_iovec_string_field(struct iovec *iovec, size_t *n_iovec, const char *field, const char *value);
char* set_iovec_string_field_free(struct iovec *iovec, size_t *n_iovec, const char *field, char *value);