add event destructor

This commit is contained in:
Bob Halley
1998-11-03 19:05:12 +00:00
parent 6d05b41aae
commit 5741be0b80
2 changed files with 4 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ typedef struct isc_taskmgr * isc_taskmgr_t;
typedef int isc_eventtype_t;
typedef isc_boolean_t (*isc_taskaction_t)(isc_task_t, isc_event_t);
typedef void (*isc_eventdestructor_t)(isc_event_t);
/*
* This structure is public because "subclassing" it may be useful when
@@ -44,6 +45,7 @@ struct isc_event {
isc_eventtype_t type;
isc_taskaction_t action;
void * arg;
isc_eventdestructor_t destroy;
LINK(struct isc_event) link;
};

View File

@@ -142,6 +142,8 @@ isc_event_free(isc_event_t *eventp) {
event = *eventp;
REQUIRE(event != NULL);
if (event->destroy != NULL)
(event->destroy)(event);
isc_mem_put(event->mctx, event, event->size);
*eventp = NULL;