diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-03-26 23:18:40 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-03-31 12:50:32 -0400 |
commit | b7442f8e8354b09f66d0110f2c5c970373a730cb (patch) | |
tree | 8b123b1b4b559c35cc39a79cc13c63024d83a7d3 /evbuffer-internal.h | |
parent | cda56abf194eb70f00c8e6ce95ec31f226048f9f (diff) | |
download | libevent-b7442f8e8354b09f66d0110f2c5c970373a730cb.tar.gz |
Replace last_with_data with a slightly smarter version
To implement evbuffer_expand() properly, you need to be able to
replace the last chunk that has data, which means that we need to keep
track of the the next pointer pointing to the last_with_data chunk,
not the last_with_data chunk itself.
Diffstat (limited to 'evbuffer-internal.h')
-rw-r--r-- | evbuffer-internal.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/evbuffer-internal.h b/evbuffer-internal.h index ce1c347d..01f5703a 100644 --- a/evbuffer-internal.h +++ b/evbuffer-internal.h @@ -81,10 +81,20 @@ struct evbuffer { /** The last chain in this buffer's linked list of chains. */ struct evbuffer_chain *last; - /** The last chain that has any data in it. If all chains in the - * buffer are empty, points to the first chain. If the buffer has no - * chains, this is NULL. */ - struct evbuffer_chain *last_with_data; + /** Pointer to the next pointer pointing at the 'last_with_data' chain. + * + * To unpack: + * + * The last_with_data chain is the last chain that has any data in it. + * If all chains in the buffer are empty, it is the first chain. + * If the buffer has no chains, it is NULL. + * + * The last_with_datap pointer points at _whatever 'next' pointer_ + * points at the last_with_datap chain. If the last_with_data chain + * is the first chain, or it is NULL, then the last_with_datap pointer + * is &buf->first. + */ + struct evbuffer_chain **last_with_datap; /** Total amount of bytes stored in all chains.*/ size_t total_len; @@ -246,7 +256,7 @@ int _evbuffer_expand_fast(struct evbuffer *, size_t, int); * Returns the number of vecs used. */ int _evbuffer_read_setup_vecs(struct evbuffer *buf, ev_ssize_t howmuch, - struct evbuffer_iovec *vecs, int n_vecs, struct evbuffer_chain **chainp, int exact); + struct evbuffer_iovec *vecs, int n_vecs, struct evbuffer_chain ***chainp, int exact); /* Helper macro: copies an evbuffer_iovec in ei to a win32 WSABUF in i. */ #define WSABUF_FROM_EVBUFFER_IOV(i,ei) do { \ |