src/util-internal.c
static getdns_return_t
add_only_addresses(struct getdns_list * addrs, ldns_rr_list * rr_list)
{
	int r = GETDNS_RETURN_GOOD;
	size_t i = 0;
	size_t item_idx = 0;

	r = getdns_list_get_length(addrs, &item_idx);
	for (i = 0; r == GETDNS_RETURN_GOOD &&
	            i < ldns_rr_list_rr_count(rr_list); ++i) {
		ldns_rr *rr = ldns_rr_list_rr(rr_list, i);
		size_t j = 0;
		size_t rd_count = ldns_rr_rd_count(rr);
		for (j = 0; r == GETDNS_RETURN_GOOD && j < rd_count; ++j) {
			ldns_rdf *rdf = ldns_rr_rdf(rr, j);
			if (ldns_rdf_get_type(rdf) != LDNS_RDF_TYPE_A &&
			    ldns_rdf_get_type(rdf) != LDNS_RDF_TYPE_AAAA) {
				continue;
			}
			struct getdns_dict *this_address =
			    getdns_dict_create_with_extended_memory_functions(
				addrs->mf.mf_arg,
				addrs->mf.mf.ext.malloc,
				addrs->mf.mf.ext.realloc,
				addrs->mf.mf.ext.free);
			if (this_address == NULL) {
				r = GETDNS_RETURN_MEMORY_ERROR;
				break;
			}
			struct getdns_bindata rbin =
				{ ldns_rdf_size(rdf), ldns_rdf_data(rdf) };
			r = getdns_dict_set_bindata(this_address,
			    GETDNS_STR_ADDRESS_TYPE,
			    ( ldns_rdf_get_type(rdf) == LDNS_RDF_TYPE_A
			    ?  &IPv4_str_bindata : &IPv6_str_bindata));
            if (r != GETDNS_RETURN_GOOD) {
                getdns_dict_destroy(this_address);
                break;
            }

			r = getdns_dict_set_bindata(this_address,
			    GETDNS_STR_ADDRESS_DATA, &rbin);
            if (r != GETDNS_RETURN_GOOD) {
                getdns_dict_destroy(this_address);
                break;
            }

			r = getdns_list_set_dict(addrs, item_idx++,
			    this_address);
			getdns_dict_destroy(this_address);
		}
	}
	return r;
}
/* helper to add the ipv4 or ipv6 bin data to the list of addrs */
helper to add the ipv4 or ipv6 bin data to the list of addrs
helper to add the ipv4 or ipv6 bin data to the list of addrs
static getdns_return_t
add_only_addresses(struct getdns_list * addrs, ldns_rr_list * rr_list)
{
	int r = GETDNS_RETURN_GOOD;
	size_t i = 0;
	size_t item_idx = 0;
	r = getdns_list_get_length(addrs, &item_idx);
	for (i = 0; r == GETDNS_RETURN_GOOD &&
	            i < ldns_rr_list_rr_count(rr_list); ++i) {
		ldns_rr *rr = ldns_rr_list_rr(rr_list, i);
		size_t j = 0;
		size_t rd_count = ldns_rr_rd_count(rr);
		for (j = 0; r == GETDNS_RETURN_GOOD && j < rd_count; ++j) {
			ldns_rdf *rdf = ldns_rr_rdf(rr, j);
			if (ldns_rdf_get_type(rdf) != LDNS_RDF_TYPE_A &&
			    ldns_rdf_get_type(rdf) != LDNS_RDF_TYPE_AAAA) {
				continue;
			}
			struct getdns_dict *this_address =
			    getdns_dict_create_with_extended_memory_functions(
				addrs->mf.mf_arg,
				addrs->mf.mf.ext.malloc,
				addrs->mf.mf.ext.realloc,
				addrs->mf.mf.ext.free);
			if (this_address == NULL) {
				r = GETDNS_RETURN_MEMORY_ERROR;
				break;
			}
			struct getdns_bindata rbin =
				{ ldns_rdf_size(rdf), ldns_rdf_data(rdf) };
			r = getdns_dict_set_bindata(this_address,
			    GETDNS_STR_ADDRESS_TYPE,
			    ( ldns_rdf_get_type(rdf) == LDNS_RDF_TYPE_A
			    ?  &IPv4_str_bindata : &IPv6_str_bindata));
            if (r != GETDNS_RETURN_GOOD) {
                getdns_dict_destroy(this_address);
                break;
            }
			r = getdns_dict_set_bindata(this_address,
			    GETDNS_STR_ADDRESS_DATA, &rbin);
            if (r != GETDNS_RETURN_GOOD) {
                getdns_dict_destroy(this_address);
                break;
            }
			r = getdns_list_set_dict(addrs, item_idx++,
			    this_address);
			getdns_dict_destroy(this_address);
		}
	}
	return r;
}
static getdns_return_t add_only_addresses ( struct getdns_list * addrs , ldns_rr_list * rr_list ) { int r = GETDNS_RETURN_GOOD ; size_t i = 0 ; size_t item_idx = 0 ; r = getdns_list_get_length ( addrs , & item_idx ) ; for ( i = 0 ; r == GETDNS_RETURN_GOOD && i < ldns_rr_list_rr_count ( rr_list ) ; ++ i ) { ldns_rr * rr = ldns_rr_list_rr ( rr_list , i ) ; size_t j = 0 ; size_t rd_count = ldns_rr_rd_count ( rr ) ; for ( j = 0 ; r == GETDNS_RETURN_GOOD && j < rd_count ; ++ j ) { ldns_rdf * rdf = ldns_rr_rdf ( rr , j ) ; if ( ldns_rdf_get_type ( rdf ) != LDNS_RDF_TYPE_A && ldns_rdf_get_type ( rdf ) != LDNS_RDF_TYPE_AAAA ) { continue ; } struct getdns_dict * this_address = getdns_dict_create_with_extended_memory_functions ( addrs -> mf . mf_arg , addrs -> mf . mf . ext . malloc , addrs -> mf . mf . ext . realloc , addrs -> mf . mf . ext . free ) ; if ( this_address == NULL ) { r = GETDNS_RETURN_MEMORY_ERROR ; break ; } struct getdns_bindata rbin = { ldns_rdf_size ( rdf ) , ldns_rdf_data ( rdf ) } ; r = getdns_dict_set_bindata ( this_address , GETDNS_STR_ADDRESS_TYPE , ( ldns_rdf_get_type ( rdf ) == LDNS_RDF_TYPE_A ? & IPv4_str_bindata : & IPv6_str_bindata ) ) ; if ( r != GETDNS_RETURN_GOOD ) { getdns_dict_destroy ( this_address ) ; break ; } r = getdns_dict_set_bindata ( this_address , GETDNS_STR_ADDRESS_DATA , & rbin ) ; if ( r != GETDNS_RETURN_GOOD ) { getdns_dict_destroy ( this_address ) ; break ; } r = getdns_list_set_dict ( addrs , item_idx ++ , this_address ) ; getdns_dict_destroy ( this_address ) ; } } return r ; }
helper to add the ipv4 or ipv6 bin data to the list of addrs
helper to add the ipv4 or ipv6 bin data to the list of addrs