Nick Mathewson eb86c8c5ff Add evbuffer_copyout to copy data from an evbuffer without draining
The evbuffer_remove() function copies data from the front of an
evbuffer into an array of char, and removes the data from the buffer.
This function behaves the same, but does not remove the data.  This
behavior can be handy for lots of protocols, where you want the
evbuffer to accumulate data until a complete record has arrived.

Lots of people have asked for a function more or less like this, and
though it isn't too hard to code one from evbuffer_peek(), it is
apparently annoying to do it in every app you write.  The
evbuffer_peek() function is significantly faster, but it requires that
the user be able to handle data in separate extents.

This patch also reimplements evbufer_remove() as evbuffer_copyout()
followed by evbuffer_drain().  I am reasonably confident that this
won't be a performance hit: the memcpy() overhead should dominate the
cost of walking the list an extra time.
2010-04-13 01:42:01 -04:00
..
2009-07-28 04:03:57 +00:00