On Tue, Oct 09, 2012 at 06:05:57PM +0800, rqslt wrote: > ??? 2012???10???09??? 17:05, Nir Soffer ??????: > > > >On Oct 9, 2012, at 6:12 AM, rqslt wrote: > > > >> I want know how to jude is the bufferevent has been free. In > >>function A , i use bufferevent_free free the bufferevetn; In > >>fuction B, how to jude is the bufferevent has been free ? > >> Who can tell me what to do ? Thanks. > > > >Check if the pointer is NULL? > > > No, the road is blocked.
Let me try translation: jude = judge, road = read? Once a bufferevent has been free()'d the pointer becomes a garbage pointer. You need to pass some structure around that can set the bufferevent variable to NULL when you free it so other functions know. Something like: struct foo { void * mydata; struct bufferevent * bev; }; void function_a(..., void * arg) { struct foo * bar = (struct foo *)arg; bufferevent_free(bar->bev); bar->bev = NULL; } void function_b(..., void * arg) { struct foo * bar = (struct foo *)arg; if (bar->bev == NULL) { /* bev is already free */ } /* whatever else */ } *********************************************************************** To unsubscribe, send an e-mail to majord...@freehaven.net with unsubscribe libevent-users in the body.