io-util: split out "struct iovec" related calls into their own .c/.h files
This is preparation for #28891, which adds a bunch more helpers around "struct iovec", at which point this really deserves its own .c/.h file. The idea is that we sooner or later can consider "struct iovec" as an entirely generic mechanism to reference some binary blob, and is the go-to type for this purpose whenever we need one.
This commit is contained in:
+1
-27
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "errno-util.h"
|
||||
#include "io-util.h"
|
||||
#include "iovec-util.h"
|
||||
#include "string-util.h"
|
||||
#include "time-util.h"
|
||||
|
||||
@@ -305,23 +306,6 @@ ssize_t sparse_write(int fd, const void *p, size_t sz, size_t run_length) {
|
||||
return q - (const uint8_t*) p;
|
||||
}
|
||||
|
||||
char* set_iovec_string_field(struct iovec *iovec, size_t *n_iovec, const char *field, const char *value) {
|
||||
char *x;
|
||||
|
||||
x = strjoin(field, value);
|
||||
if (x)
|
||||
iovec[(*n_iovec)++] = IOVEC_MAKE_STRING(x);
|
||||
return x;
|
||||
}
|
||||
|
||||
char* set_iovec_string_field_free(struct iovec *iovec, size_t *n_iovec, const char *field, char *value) {
|
||||
char *x;
|
||||
|
||||
x = set_iovec_string_field(iovec, n_iovec, field, value);
|
||||
free(value);
|
||||
return x;
|
||||
}
|
||||
|
||||
struct iovec_wrapper *iovw_new(void) {
|
||||
return malloc0(sizeof(struct iovec_wrapper));
|
||||
}
|
||||
@@ -429,13 +413,3 @@ rollback:
|
||||
target->count = original_count;
|
||||
return r;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user