2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 05:28:00 +00:00

Describe and enforce the contract for isc_event_allocate().

Silent failure for bad args is not the BIND 9 way.
This commit is contained in:
Mark Andrews 2000-09-27 22:53:33 +00:00
parent caa1ba7ea9
commit cd5475efa4
2 changed files with 23 additions and 8 deletions

View File

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: event.c,v 1.13 2000/08/01 01:29:21 tale Exp $ */
/* $Id: event.c,v 1.14 2000/09/27 22:53:31 marka Exp $ */
/*
* Principal Author: Bob Halley
@ -45,10 +45,8 @@ isc_event_allocate(isc_mem_t *mctx, void *sender, isc_eventtype_t type,
isc_event_t *event;
void *deconst_arg;
if (size < sizeof (struct isc_event))
return (NULL);
if (action == NULL)
return (NULL);
REQUIRE(size >= sizeof (struct isc_event));
REQUIRE(action != NULL);
event = isc_mem_get(mctx, size);
if (event == NULL)

View File

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: event.h,v 1.22 2000/08/01 01:30:08 tale Exp $ */
/* $Id: event.h,v 1.23 2000/09/27 22:53:33 marka Exp $ */
#ifndef ISC_EVENT_H
#define ISC_EVENT_H 1
@ -85,8 +85,25 @@ struct isc_event {
ISC_LANG_BEGINDECLS
isc_event_t *
isc_event_allocate(isc_mem_t *, void *, isc_eventtype_t, isc_taskaction_t,
const void *arg, size_t);
isc_event_allocate(isc_mem_t *mctx, void *sender, isc_eventtype_t type,
isc_taskaction_t action, const void *arg, size_t size);
/*
* Allocate and initalise in a structure with initial elements
* defined by:
*
* struct {
* ISC_EVENT_COMMON(struct isc_event);
* ...
* };
*
* Requires:
* 'size' >= sizeof(struct isc_event)
* 'action' to be non NULL
*
* Returns:
* a pointer to a initalised structure of the requested size.
* NULL if unable to allocate memory.
*/
void
isc_event_free(isc_event_t **);