support new destroy method; attributes; reorder structure members
This commit is contained in:
@@ -29,6 +29,13 @@
|
||||
*** Events.
|
||||
***/
|
||||
|
||||
static void
|
||||
destroy(isc_event_t *event) {
|
||||
isc_mem_t *mctx = event->destroy_arg;
|
||||
|
||||
isc_mem_put(mctx, event, event->size);
|
||||
}
|
||||
|
||||
isc_event_t *
|
||||
isc_event_allocate(isc_mem_t *mctx, void *sender, isc_eventtype_t type,
|
||||
isc_taskaction_t action, void *arg, size_t size)
|
||||
@@ -43,13 +50,14 @@ isc_event_allocate(isc_mem_t *mctx, void *sender, isc_eventtype_t type,
|
||||
event = isc_mem_get(mctx, size);
|
||||
if (event == NULL)
|
||||
return (NULL);
|
||||
event->mctx = mctx;
|
||||
event->size = size;
|
||||
event->sender = sender;
|
||||
event->attributes = 0;
|
||||
event->type = type;
|
||||
event->sender = sender;
|
||||
event->action = action;
|
||||
event->arg = arg;
|
||||
event->destroy = NULL;
|
||||
event->destroy = destroy;
|
||||
event->destroy_arg = mctx;
|
||||
ISC_LINK_INIT(event, link);
|
||||
|
||||
return (event);
|
||||
@@ -65,7 +73,6 @@ isc_event_free(isc_event_t **eventp) {
|
||||
|
||||
if (event->destroy != NULL)
|
||||
(event->destroy)(event);
|
||||
isc_mem_put(event->mctx, event, event->size);
|
||||
|
||||
*eventp = NULL;
|
||||
}
|
||||
|
||||
@@ -31,19 +31,34 @@ ISC_LANG_BEGINDECLS
|
||||
|
||||
typedef void (*isc_eventdestructor_t)(isc_event_t *);
|
||||
|
||||
/*
|
||||
* XXXRTH These fields may soon be prefixed with something like "ev_"
|
||||
* so that there's no way someone using ISC_EVENT_COMMON could
|
||||
* have a namespace conflict with us.
|
||||
*
|
||||
* On the other hand, if we ever changed the contents of this
|
||||
* structure, we'd break binary compatibility, so maybe this isn't
|
||||
* really an issue.
|
||||
*/
|
||||
#define ISC_EVENT_COMMON(ltype) \
|
||||
size_t size; \
|
||||
unsigned int attributes; \
|
||||
isc_eventtype_t type; \
|
||||
isc_taskaction_t action; \
|
||||
void * arg; \
|
||||
void * sender; \
|
||||
isc_eventdestructor_t destroy; \
|
||||
void * destroy_arg; \
|
||||
ISC_LINK(ltype) link
|
||||
|
||||
#define ISC_EVENTATTR_NOPURGE 0x00000001
|
||||
|
||||
/*
|
||||
* This structure is public because "subclassing" it may be useful when
|
||||
* defining new event types.
|
||||
*/
|
||||
struct isc_event {
|
||||
isc_mem_t * mctx;
|
||||
size_t size;
|
||||
void * sender;
|
||||
isc_eventtype_t type;
|
||||
isc_taskaction_t action;
|
||||
void * arg;
|
||||
isc_eventdestructor_t destroy;
|
||||
ISC_LINK(struct isc_event) link;
|
||||
ISC_EVENT_COMMON(struct isc_event);
|
||||
};
|
||||
|
||||
#define ISC_EVENTTYPE_FIRSTEVENT 0x00000000
|
||||
|
||||
Reference in New Issue
Block a user