From df9ff0a119e6a116b9292f7c778200ef5d1fb24b Mon Sep 17 00:00:00 2001 From: Ted Lemon Date: Mon, 1 May 2000 23:47:08 +0000 Subject: [PATCH] Add support for omapi_addr_list_t. --- omapip/alloc.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/omapip/alloc.c b/omapip/alloc.c index 40d9b003..05f4a196 100644 --- a/omapip/alloc.c +++ b/omapip/alloc.c @@ -806,3 +806,80 @@ isc_result_t omapi_value_dereference (omapi_value_t **h, return ISC_R_SUCCESS; } +isc_result_t omapi_addr_list_new (omapi_addr_list_t **d, unsigned count, + const char *file, int line) +{ + omapi_addr_list_t *new; + + new = dmalloc ((count * sizeof (omapi_addr_t)) + + sizeof (omapi_addr_list_t), file, line); + if (!new) + return ISC_R_NOMEMORY; + memset (new, 0, ((count * sizeof (omapi_addr_t)) + + sizeof (omapi_addr_list_t))); + new -> count = count; + new -> addresses = (omapi_addr_t *)(new + 1); + return omapi_addr_list_reference (d, new, file, line); +} + +isc_result_t omapi_addr_list_reference (omapi_addr_list_t **r, + omapi_addr_list_t *h, + const char *file, int line) +{ + if (!h || !r) + return ISC_R_INVALIDARG; + + if (*r) { +#if defined (POINTER_DEBUG) + log_error ("%s(%d): reference store into non-null pointer!", + file, line); + abort (); +#else + return ISC_R_INVALIDARG; +#endif + } + *r = h; + h -> refcnt++; + rc_register (file, line, r, h, h -> refcnt); + dmalloc_reuse (h, file, line, 1); + return ISC_R_SUCCESS; +} + +isc_result_t omapi_addr_list_dereference (omapi_addr_list_t **h, + const char *file, int line) +{ + if (!h) + return ISC_R_INVALIDARG; + + if (!*h) { +#if defined (POINTER_DEBUG) + log_error ("%s(%d): dereference of null pointer!", file, line); + abort (); +#else + return ISC_R_INVALIDARG; +#endif + } + + if ((*h) -> refcnt <= 0) { +#if defined (POINTER_DEBUG) + log_error ("%s(%d): dereference of pointer with zero refcnt!", + file, line); +#if defined (DEBUG_RC_HISTORY) + dump_rc_history (); +#endif + abort (); +#else + *h = 0; + return ISC_R_INVALIDARG; +#endif + } + + --((*h) -> refcnt); + rc_register (file, line, h, *h, (*h) -> refcnt); + if ((*h) -> refcnt <= 0 ) { + dfree (*h, file, line); + } + *h = 0; + return ISC_R_SUCCESS; +} +