On Thu, Nov 11, 2010 at 10:42 PM, Kevin BowlingUgly? You bet! evbuffer_peek is really only optimized for the case
<kevin.bowling@xxxxxxxxxx> wrote:
> Hi,
>
> I've seen a few mails talking about evbuffer_peek, but no solid usage of
> it. The doxygen on the libevent page doesn't cover it generating my own
> from 2.0.8 has shed little light on its use to me.
where you do not want to take any performance hit for copying data out
of the evbuffer, and you're willing to make your code more complex
because of it. Instead, I'd suggest evbuffer_copyout(), which is way
easier for what you seem to be doing:
uint8_t tmp[3];
if (evbuffer_copyout(input, tmp, 3) < 3)
return -1;
ulen = (tmp[1]<<8) | tmp[2];