mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
Tweaks, fixups, and comments on evbuffer_add_iovec
This commit is contained in:
parent
aaec5aca01
commit
27b5398fe0
7
buffer.c
7
buffer.c
@ -603,11 +603,16 @@ evbuffer_add_iovec(struct evbuffer * buf, struct evbuffer_iovec * vec, int n_vec
|
||||
to_alloc += vec[n].iov_len;
|
||||
}
|
||||
|
||||
if (evbuffer_expand(buf, to_alloc) < 0) {
|
||||
if (_evbuffer_expand_fast(buf, to_alloc, 2) < 0) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
for (n = 0; n < n_vec; n++) {
|
||||
/* XXX each 'add' call here does a bunch of setup that's
|
||||
* obviated by _evbuffer_expand_fast, and some cleanup that we
|
||||
* would like to do only once. Instead we should just extract
|
||||
* the part of the code that's needed. */
|
||||
|
||||
if (evbuffer_add(buf, vec[n].iov_base, vec[n].iov_len) < 0) {
|
||||
goto done;
|
||||
}
|
||||
|
@ -1837,6 +1837,7 @@ test_evbuffer_add_iovec(void * ptr)
|
||||
"On the one hand, it cuts for Justice, imposing practical morality upon those who fear it.",
|
||||
"Conscience does not always adhere to rational judgment.",
|
||||
"Guilt is always a self-imposed burden, but it is not always rightly imposed."
|
||||
/* -- R.A. Salvatore, _Sojurn_ */
|
||||
};
|
||||
size_t expected_length = 0;
|
||||
size_t returned_length = 0;
|
||||
@ -1846,7 +1847,7 @@ test_evbuffer_add_iovec(void * ptr)
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
vec[i].iov_len = strlen(data[i]);
|
||||
vec[i].iov_base = data[i];
|
||||
vec[i].iov_base = (char*) data[i];
|
||||
expected_length += vec[i].iov_len;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user