summaryrefslogtreecommitdiff
path: root/ot_iovec.c
diff options
context:
space:
mode:
Diffstat (limited to 'ot_iovec.c')
-rw-r--r--ot_iovec.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/ot_iovec.c b/ot_iovec.c
index fec3912..f9567a9 100644
--- a/ot_iovec.c
+++ b/ot_iovec.c
@@ -35,6 +35,26 @@ void *iovec_increase( int *iovec_entries, struct iovec **iovector, size_t new_al
35 return new_data; 35 return new_data;
36} 36}
37 37
38void *iovec_append( int *iovec_entries, struct iovec **iovector, struct iovec *append_iovector) {
39 int new_entries = *iovec_entries + 1;
40 struct iovec *new_vec = realloc( *iovector, new_entries * sizeof( struct iovec ) );
41 if( !new_vec )
42 return NULL;
43
44 /* Take over data from appended iovec */
45 new_vec[*iovec_entries].iov_base = append_iovector->iov_base;
46 new_vec[*iovec_entries].iov_len = append_iovector->iov_len;
47
48 append_iovector->iov_base = NULL;
49 append_iovector->iov_len = 0;
50
51 *iovector = new_vec;
52 *iovec_entries = new_entries;
53
54 return new_vec;
55}
56
57
38void iovec_free( int *iovec_entries, struct iovec **iovector ) { 58void iovec_free( int *iovec_entries, struct iovec **iovector ) {
39 int i; 59 int i;
40 for( i=0; i<*iovec_entries; ++i ) 60 for( i=0; i<*iovec_entries; ++i )
@@ -64,7 +84,6 @@ void *iovec_fix_increase_or_free( int *iovec_entries, struct iovec **iovector, v
64 return new_data; 84 return new_data;
65} 85}
66 86
67
68size_t iovec_length( const int *iovec_entries, const struct iovec **iovector ) { 87size_t iovec_length( const int *iovec_entries, const struct iovec **iovector ) {
69 size_t length = 0; 88 size_t length = 0;
70 int i; 89 int i;