From a9de67bf3557928af4d4b172bc5b083479844168 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Sat, 18 Mar 2000 00:34:53 +0000 Subject: [PATCH] Call the destroy_action callback in an object, if it exists, after omapi_object_dereference has freed the memory allocated for the object. --- lib/omapi/object.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/omapi/object.c b/lib/omapi/object.c index 26047f9d81..98d509f78e 100644 --- a/lib/omapi/object.c +++ b/lib/omapi/object.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: object.c,v 1.13 2000/03/14 03:43:06 tale Exp $ */ +/* $Id: object.c,v 1.14 2000/03/18 00:34:53 tale Exp $ */ /* Principal Author: Ted Lemon */ @@ -188,6 +188,9 @@ omapi_object_dereference(omapi_object_t **h) { extra_references = 0; if (extra_references == 0) { + isc_taskaction_t action = (*h)->destroy_action; + void *arg = (*h)->destroy_arg; + if (inner_reference != 0) OBJECT_DEREF(&(*h)->inner); if (outer_reference != 0) @@ -196,6 +199,18 @@ omapi_object_dereference(omapi_object_t **h) { (*((*h)->type->destroy))(*h); (*h)->refcnt = 0; isc_mem_put(omapi_mctx, *h, (*h)->object_size); + + if (action != NULL) { + isc_event_t *event; + + event = isc_event_allocate(omapi_mctx, *h, + OMAPI_EVENT_OBJECTFREED, + action, arg, + sizeof(isc_event_t)); + if (event != NULL) + isc_task_send(omapi_task, &event); + } + } else (*h)->refcnt--;