iovec-util: introduce several helper functions

This commit is contained in:
Yu Watanabe
2026-06-27 14:04:48 +09:00
parent ee6522d036
commit 82ff3f71f5
2 changed files with 29 additions and 0 deletions
+9
View File
@@ -10,6 +10,8 @@
extern const struct iovec iovec_nul_byte; /* Points to a single NUL byte */
extern const struct iovec iovec_empty; /* Points to an empty, but valid (i.e. non-NULL) pointer */
int iovec_alloc(size_t n, struct iovec *ret);
size_t iovec_total_size(const struct iovec *iovec, size_t n) _nonnull_if_nonzero_(1, 2);
bool iovec_inc_many(struct iovec *iovec, size_t n, size_t k) _nonnull_if_nonzero_(1, 2);
@@ -31,6 +33,13 @@ struct iovec* iovec_make_string(struct iovec *iovec, const char *s);
.iov_len = 1, \
}
#define IOVEC_ALLOCA(n) \
({ \
size_t _n_ = (n); \
IOVEC_MAKE(alloca_safe(_n_), _n_); \
})
void iovec_erase(struct iovec *iovec);
void iovec_done_erase(struct iovec *iovec);
char* set_iovec_string_field(struct iovec *iovec, size_t *n_iovec, const char *field, const char *value);