]> granicus.if.org Git - libevent/commitdiff
Tweaks, fixups, and comments on evbuffer_add_iovec
authorNick Mathewson <nickm@torproject.org>
Fri, 11 Nov 2011 22:56:08 +0000 (17:56 -0500)
committerNick Mathewson <nickm@torproject.org>
Fri, 11 Nov 2011 22:56:08 +0000 (17:56 -0500)
buffer.c
test/regress_buffer.c

index e4096553f478ab93f18475ab16c91eea78d95b75..f1fb556fd647b7fbb2410452d67b592aafcdd136 100644 (file)
--- a/buffer.c
+++ b/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;
                }
index 7fdfffdc308a7a92ce3843e1bbb8d161d6a9cecc..fc78ef095300a9d4dcac07c38a13f0ebe0169139 100644 (file)
@@ -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;
        }