2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-24 19:18:50 +00:00
bind/lib/isc/event.c

66 lines
1.4 KiB
C
Raw Normal View History

1999-05-10 22:51:19 +00:00
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* SPDX-License-Identifier: MPL-2.0
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
1999-05-10 22:51:19 +00:00
*/
/*!
* \file
1999-05-10 22:51:19 +00:00
*/
#include <isc/event.h>
#include <isc/mem.h>
2000-04-28 01:12:23 +00:00
#include <isc/util.h>
1999-05-10 22:51:19 +00:00
/***
*** Events.
***/
static void
2020-02-13 14:44:37 -08:00
destroy(isc_event_t *event) {
isc_mem_t *mctx = event->ev_destroy_arg;
isc_mem_put(mctx, event, event->ev_size);
}
1999-05-10 22:51:19 +00:00
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 ISC__EVENT_FLARG) {
isc_event_t *event;
REQUIRE(size >= sizeof(struct isc_event));
REQUIRE(action != NULL);
event = isc_mem_get(mctx, size);
ISC_EVENT_INIT_PASS(event, size, 0, NULL, type, action, arg, sender,
destroy, mctx);
return (event);
}
1999-05-10 22:51:19 +00:00
void
2020-02-13 14:44:37 -08:00
isc_event_free(isc_event_t **eventp) {
1999-05-10 22:51:19 +00:00
isc_event_t *event;
1999-05-10 22:51:19 +00:00
REQUIRE(eventp != NULL);
event = *eventp;
*eventp = NULL;
1999-05-10 22:51:19 +00:00
REQUIRE(event != NULL);
REQUIRE(!ISC_LINK_LINKED(event, ev_link));
REQUIRE(!ISC_LINK_LINKED(event, ev_ratelink));
if (event->ev_destroy != NULL) {
(event->ev_destroy)(event);
}
1999-05-10 22:51:19 +00:00
}