2 * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1998-2001 Internet Software Consortium.
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: event.c,v 1.17.18.2 2005/04/29 00:16:45 marka Exp $ */
22 * \author Principal Author: Bob Halley
27 #include <isc/event.h>
36 destroy(isc_event_t *event) {
37 isc_mem_t *mctx = event->ev_destroy_arg;
39 isc_mem_put(mctx, event, event->ev_size);
43 isc_event_allocate(isc_mem_t *mctx, void *sender, isc_eventtype_t type,
44 isc_taskaction_t action, const void *arg, size_t size)
49 REQUIRE(size >= sizeof(struct isc_event));
50 REQUIRE(action != NULL);
52 event = isc_mem_get(mctx, size);
57 * Removing the const attribute from "arg" is the best of two
58 * evils here. If the event->ev_arg member is made const, then
59 * it affects a great many users of the task/event subsystem
60 * which are not passing in an "arg" which starts its life as
61 * const. Changing isc_event_allocate() and isc_task_onshutdown()
62 * to not have "arg" prototyped as const (which is quite legitimate,
63 * because neither of those functions modify arg) can cause
64 * compiler whining anytime someone does want to use a const
65 * arg that they themselves never modify, such as with
66 * gcc -Wwrite-strings and using a string "arg".
68 DE_CONST(arg, deconst_arg);
70 ISC_EVENT_INIT(event, size, 0, NULL, type, action, deconst_arg,
71 sender, destroy, mctx);
77 isc_event_free(isc_event_t **eventp) {
80 REQUIRE(eventp != NULL);
82 REQUIRE(event != NULL);
84 if (event->ev_destroy != NULL)
85 (event->ev_destroy)(event);