[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] evbuffer_pullup(x,-1): garbage at end?



  Hi Bas,

Le Sat, Sep 25, 2010 at 12:39:14AM +0200, Bas Verhoeven ecrivait :
> The client uses 'evbuffer_pullup(buffer, -1)' to get a char*
> containing all data received. When testing with 'evbuffer_readln()'
> the garbage does not show up. Packet sniffing has also shown that
> that extra data is not being sent by the webserver.

  This is totally expected.
  
  evbuffer_pullup() makes the data continuous, but doesn't change anything
to the data itself. It's treated as binary data, not as a zero-terminated
string.

  evbuffer_readln() actually creates a new buffer and copies the data into
it, appending an extra zero by the way.

  Not sure about what you're trying to achieve, but if you can consider data
as a buffer pointer + buffer size, it's a good way to improve the overall
performance of your app (zero copy) over using C-strings.

  Best regards,   

-- 
Frank Denis - j [at] pureftpd.org - http://00f.net
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.