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

[Libevent-users] When can an event be freed?



Hi folks

I have a hopefully quick question. I've been chasing down memory corruption issues, and think I'm coming to closure on the root cause.

If I setup an event by malloc'ing an event_t, am I allowed to free that memory in the event handler when called by libevent? Or does libevent still need to do something with the event after the callback completes?

In other words, can I do this:

In code that sets up the event:

struct event_t *ev;

ev = (struct event_t*)malloc(sizeof(struct event_t);
…
trigger_event



In event handler:

struct event_t *ev = (struct event_t*)cbdata;
…..
free(ev);
return


***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.