Files
Evan Hunt 10accd6260 clean up uses of ISC_R_NOMEMORY
the isc_mem allocation functions can no longer fail; as a result,
ISC_R_NOMEMORY is now rarely used: only when an external library
such as libjson-c or libfstrm could return NULL. (even in
these cases, arguably we should assert rather than returning
ISC_R_NOMEMORY.)

code and comments that mentioned ISC_R_NOMEMORY have been
cleaned up, and the following functions have been changed to
type void, since (in most cases) the only value they could
return was ISC_R_SUCCESS:

- dns_dns64_create()
- dns_dyndb_create()
- dns_ipkeylist_resize()
- dns_kasp_create()
- dns_kasp_key_create()
- dns_keystore_create()
- dns_order_create()
- dns_order_add()
- dns_peerlist_new()
- dns_tkeyctx_create()
- dns_view_create()
- dns_zone_setorigin()
- dns_zone_setfile()
- dns_zone_setstream()
- dns_zone_getdbtype()
- dns_zone_setjournal()
- dns_zone_setkeydirectory()
- isc_lex_openstream()
- isc_portset_create()
- isc_symtab_create()

(the exception is dns_view_create(), which could have returned
other error codes in the event of a crypto library failure when
calling isc_file_sanitize(), but that should be a RUNTIME_CHECK
anyway.)
2025-01-23 15:54:57 -08:00

86 lines
2.0 KiB
C

/*
* 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.
*/
#pragma once
#include <inttypes.h>
#include <isc/types.h>
#include <dns/types.h>
/*%
* A structure holding a list of addresses and keys. Used to store
* primaries for a secondary zone, created by parsing config options.
*/
struct dns_ipkeylist {
isc_sockaddr_t *addrs;
isc_sockaddr_t *sources;
dns_name_t **keys;
dns_name_t **tlss;
dns_name_t **labels;
uint32_t count;
uint32_t allocated;
};
void
dns_ipkeylist_init(dns_ipkeylist_t *ipkl);
/*%<
* Reset ipkl to empty state
*
* Requires:
*\li 'ipkl' to be non NULL.
*/
void
dns_ipkeylist_clear(isc_mem_t *mctx, dns_ipkeylist_t *ipkl);
/*%<
* Free `ipkl` contents using `mctx`.
*
* After this call, `ipkl` is a freshly cleared structure with all
* pointers set to `NULL` and count set to 0.
*
* Requires:
*\li 'mctx' to be a valid memory context.
*\li 'ipkl' to be non NULL.
*/
isc_result_t
dns_ipkeylist_copy(isc_mem_t *mctx, const dns_ipkeylist_t *src,
dns_ipkeylist_t *dst);
/*%<
* Deep copy `src` into empty `dst`, allocating `dst`'s contents.
*
* Requires:
*\li 'mctx' to be a valid memory context.
*\li 'src' to be non NULL
*\li 'dst' to be non NULL and point to an empty \ref dns_ipkeylist_t
* with all pointers set to `NULL` and count set to 0.
*
* Returns:
*\li #ISC_R_SUCCESS -- success
*\li any other value -- failure
*/
void
dns_ipkeylist_resize(isc_mem_t *mctx, dns_ipkeylist_t *ipkl, unsigned int n);
/*%<
* Resize ipkl to contain n elements. Size (count) is not changed, and the
* added space is zeroed.
*
* Requires:
* \li 'mctx' to be a valid memory context.
* \li 'ipk' to be non NULL
* \li 'n' >= ipkl->count
*/