2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-30 13:57:50 +00:00

Add support for omapi_addr_list_t.

This commit is contained in:
Ted Lemon 2000-05-01 23:47:08 +00:00
parent b7137154ca
commit df9ff0a119

View File

@ -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;
}