]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/iovec-util.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
8 #include "alloc-util.h"
11 size_t iovec_total_size(const struct iovec
*iovec
, size_t n
);
13 bool iovec_increment(struct iovec
*iovec
, size_t n
, size_t k
);
15 #define IOVEC_MAKE(base, len) (struct iovec) { .iov_base = (base), .iov_len = (len) }
16 #define IOVEC_MAKE_STRING(string) \
18 const char *_s = (string); \
19 IOVEC_MAKE((char*) _s, strlen(_s)); \
22 static inline void iovec_done(struct iovec
*iovec
) {
23 /* A _cleanup_() helper that frees the iov_base in the iovec */
26 iovec
->iov_base
= mfree(iovec
->iov_base
);
30 static inline void iovec_done_erase(struct iovec
*iovec
) {
33 iovec
->iov_base
= erase_and_free(iovec
->iov_base
);
37 static inline bool iovec_is_set(const struct iovec
*iovec
) {
38 return iovec
&& iovec
->iov_len
> 0 && iovec
->iov_base
;
41 char* set_iovec_string_field(struct iovec
*iovec
, size_t *n_iovec
, const char *field
, const char *value
);
42 char* set_iovec_string_field_free(struct iovec
*iovec
, size_t *n_iovec
, const char *field
, char *value
);
44 void iovec_array_free(struct iovec
*iovec
, size_t n_iovec
);