summaryrefslogtreecommitdiff
path: root/ot_iovec.c
diff options
context:
space:
mode:
Diffstat (limited to 'ot_iovec.c')
-rw-r--r--ot_iovec.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/ot_iovec.c b/ot_iovec.c
index cd5b9f9..7e5903f 100644
--- a/ot_iovec.c
+++ b/ot_iovec.c
@@ -7,12 +7,10 @@
7#include <stdlib.h> 7#include <stdlib.h>
8#include <sys/uio.h> 8#include <sys/uio.h>
9 9
10/* Libowfat */
11
12/* Opentracker */ 10/* Opentracker */
13#include "ot_iovec.h" 11#include "ot_iovec.h"
14 12
15void *iovec_increase(size_t *iovec_entries, struct iovec **iovector, size_t new_alloc) { 13void *iovec_new_chunk(size_t *iovec_entries, struct iovec **iovector, size_t new_alloc) {
16 void *new_data; 14 void *new_data;
17 size_t new_entries = 1 + *iovec_entries; 15 size_t new_entries = 1 + *iovec_entries;
18 struct iovec *new_vec = realloc(*iovector, new_entries * sizeof(struct iovec)); 16 struct iovec *new_vec = realloc(*iovector, new_entries * sizeof(struct iovec));
@@ -62,7 +60,7 @@ void iovec_free(size_t *iovec_entries, struct iovec **iovector) {
62 *iovec_entries = 0; 60 *iovec_entries = 0;
63} 61}
64 62
65void iovec_fixlast(size_t *iovec_entries, struct iovec **iovector, void *last_ptr) { 63void iovec_trim_last(size_t *iovec_entries, struct iovec **iovector, void *last_ptr) {
66 if (*iovec_entries) { 64 if (*iovec_entries) {
67 char *base = (char *)((*iovector)[*iovec_entries - 1]).iov_base; 65 char *base = (char *)((*iovector)[*iovec_entries - 1]).iov_base;
68 size_t new_alloc = ((char *)last_ptr) - base; 66 size_t new_alloc = ((char *)last_ptr) - base;
@@ -72,12 +70,12 @@ void iovec_fixlast(size_t *iovec_entries, struct iovec **iovector, void *last_pt
72 } 70 }
73} 71}
74 72
75void *iovec_fix_increase_or_free(size_t *iovec_entries, struct iovec **iovector, void *last_ptr, size_t new_alloc) { 73void *iovec_next_chunk(size_t *iovec_entries, struct iovec **iovector, void *last_ptr, size_t new_alloc) {
76 void *new_data; 74 void *new_data;
77 75
78 iovec_fixlast(iovec_entries, iovector, last_ptr); 76 iovec_trim_last(iovec_entries, iovector, last_ptr);
79 77
80 if (!(new_data = iovec_increase(iovec_entries, iovector, new_alloc))) 78 if (!(new_data = iovec_new_chunk(iovec_entries, iovector, new_alloc)))
81 iovec_free(iovec_entries, iovector); 79 iovec_free(iovec_entries, iovector);
82 80
83 return new_data; 81 return new_data;