summaryrefslogtreecommitdiff
path: root/evbuffer-internal.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-03-10 22:16:14 -0500
committerNick Mathewson <nickm@torproject.org>2010-03-10 22:16:14 -0500
commit2a6d2a1e4be261e071f5ddb95be183e172643916 (patch)
treed0a3416450a8e6cc0816c355f387f55dce82124b /evbuffer-internal.h
parentc7f1b820fcf3181bccae4dc72dd2d16fbe712887 (diff)
downloadlibevent-2a6d2a1e4be261e071f5ddb95be183e172643916.tar.gz
Revise evbuffer to add last_with_data
This is the first patch in a series to replace previous_to_last with last_with_data. Currently, we can only use two partially empty chains at the end of an evbuffer, so if we have one with 511 bytes free, and another with 512 bytes free, and we try to do a 1024 byte read, we can't just stick another chain on the end: we need to reallocate the last one. That's stupid and inefficient. Instead, this patch adds a last_with_data pointer to eventually replace previous_to_last. Instead of pointing to the penultimated chain (if any) as previous_to_last does, last_with_data points to the last chain that has any data in it, if any. If all chains are empty, last_with_data points to the first chain. If there are no chains, last_with_data is NULL. The next step is to start using last_with_data everywhere that we currently use previous_to_last. When that's done, we can remove previous_to_last and the code that maintains it.
Diffstat (limited to 'evbuffer-internal.h')
-rw-r--r--evbuffer-internal.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/evbuffer-internal.h b/evbuffer-internal.h
index 894dc2f1..ff599077 100644
--- a/evbuffer-internal.h
+++ b/evbuffer-internal.h
@@ -84,6 +84,10 @@ struct evbuffer {
* repurposed accordingly. */
struct evbuffer_chain *previous_to_last;
+ /** The last chain that has any data in it. If all chains in the
+ * buffer are empty, points to the first chain */
+ struct evbuffer_chain *last_with_data;
+
/** Total amount of bytes stored in all chains.*/
size_t total_len;