Nothing in the description of evbuffer_pullup() suggests to me that this would need to happen.
There’s no discussion about freeing the returned memory, for instance, which would need to happen if it were a separate buffer. But there’s a simple test: try calling evbuffer_pullup() on the same buffer twice before draining it, and see if the pointer returned both times is the same… -Philip > On Nov 15, 2016, at 1:29 PM, Devi Prasad Ivaturi <[email protected]> wrote: > > Also, isn't the buffer returned by pullup() is only for peeking and NOT > modifying the buffer? > I understand it that way from > http://www.wangafu.net/~nickm/libevent-book/Ref7_evbuffer.html > <http://www.wangafu.net/~nickm/libevent-book/Ref7_evbuffer.html> > > Regards, > -devi > > On Tue, Nov 15, 2016 at 12:27 PM, Devi Prasad Ivaturi <[email protected] > <mailto:[email protected]>> wrote: > In the front only, if you want to call it that way. > > Say, I want to just modify the TTL or TOS values of IP header of a network > packet (accessed using evbuffer API) > passing through my box: don't want to use pullup() which is costly, since, > the IP header could be a few headers > away from the beginning (MAC + other enapsulations). > > I don't understand how add_reference() would meet the need: I want to modify > the bytes in the packet headers, from > less than a byte upto 16 bytes max. > > Regards, > -devi > > On Tue, Nov 15, 2016 at 11:35 AM, Philip Prindeville > <[email protected] > <mailto:[email protected]>> wrote: > Where in the buffer is the data? Is it near the front or not? > > If it’s near the front, then use evbuffer_pullup(). Otherwise, you could > provide your own underlying storage with evbuffer_add_reference(). > > > >> On Nov 15, 2016, at 11:58 AM, Devi Prasad Ivaturi <[email protected] >> <mailto:[email protected]>> wrote: >> >> And I get the impression that these API are to insert data rather than >> modify existing data. >> >> >> On Nov 15, 2016 10:43 AM, "Devi Prasad Ivaturi" <[email protected] >> <mailto:[email protected]>> wrote: >> BTW, I did consider reserve/commit space API, but, thought they might be an >> overkill. I prefer peeking the byte location and modifying it. >> >> >> On Nov 15, 2016 10:12 AM, "Devi Prasad Ivaturi" <[email protected] >> <mailto:[email protected]>> wrote: >> How can I modify a byte or two directly in evbuffer data? >> >> >> > > >
