Thank you again!
发件人: Sanjiv <sanjiv....@gmail.com> 答复: <libevent-us...@freehaven.net> 日期: Fri, 20 Apr 2012 08:24:14 +0530 至: <libevent-us...@freehaven.net> 主题: Re: [Libevent-users] How can I write exact length of a evbuffer? That's right, you can use event_free() to free a timer. If your event loop is still active , I would recommed a evtimer_del() before event_free(). -- Sanjiv On Fri, Apr 20, 2012 at 7:17 AM, Dawen Rie <dawenh...@126.com> wrote: > Thank you very much, my problem solved! > Can I ask other question? > I find the evtimer_* macro as follow. It has evtimer_new but no > evtimer_free? Is it means I don't need to free a evtimer_new return > pointer? But I notice evtimer_new was defined as event_new, so I think it > must be free by event_free, is it write? I had check the > sample/timer_test.c, It just demo a stack base usage. > > /** > @name evtimer_* macros > > Aliases for working with one-shot timer events */ > /**@{*/ > #define evtimer_assign(ev, b, cb, arg) \ > event_assign((ev), (b), -1, 0, (cb), (arg)) > #define evtimer_new(b, cb, arg) event_new((b), -1, 0, (cb), (arg)) > #define evtimer_add(ev, tv) event_add((ev), (tv)) > #define evtimer_del(ev) event_del(ev) > #define evtimer_pending(ev, tv) event_pending((ev), EV_TIMEOUT, (tv)) > #define evtimer_initialized(ev) event_initialized(ev) > /**@}*/ > > > > > 在 12-4-19 下午11:02, "Nick Mathewson" <ni...@freehaven.net> 写入: > >> >On Sat, Apr 14, 2012 at 4:15 AM, Dawen Rie <dawenh...@126.com> wrote: >>> >> Hello everybody. I am a new user of libevent. I can't find the correct >>> >>API >>> >> to do my work. >>> >> I had found the API: >>> >> >>> >> int bufferevent_write_buffer(struct bufferevent *bufev, struct evbuffer >>> >> *buf); >>> >> It will send all data of evbuffer. But I just want to send a special >>> >> length not all. >>> >> >>> >> And API: >>> >> int bufferevent_write(struct bufferevent *bufev, const void *data, >>> >>size_t >>> >> size); >>> >> >>> >> >>> >> It require me copy out the data from evbuffer, I think it's >>> >>inefficiency. >>> >> >>> >> So, is there andy API like: >>> >> int bufferevent_write_buffer(struct bufferevent *bufev, struct evbuffer >>> >> *buf, size_t size); >>> >> >>> >> It just send size of data in but? >> > >> >Hi! >> > >> >What you want to be looking at first is bufferevent_get_output(). It >> >returns an output evbuffer that you can add data to manually. The >> >bufferevent_write() and bufferevent_write_buffer() functions are thin >> >wrappers around bufferevent_get_output() and one of the evbuffer_* >> >functions. >> > >> >So now the question becomes, "how can I add move (but not all) of the >> >data from one evbuffer to another?" >> > >> >For that, see evbuffer_remove_buffer(). >> > >> >For more information, you might want to read the (perpetually >> >work-in-progress) reference manual at >> >http://www.wangafu.net/~nickm/libevent-book/ >> > >> >yrs, >> >-- >> >Nick >> >*********************************************************************** >> >To unsubscribe, send an e-mail to majord...@freehaven.net with >> >unsubscribe libevent-users in the body. > > > > *********************************************************************** > To unsubscribe, send an e-mail to majord...@freehaven.net with > unsubscribe libevent-users in the body. -- Sanjiv Raj Marvin: I've been talking to the ship's computer. Arthur: And? Marvin: It hates me.