From: Jelte Jansen Date: Tue, 4 Apr 2006 13:33:05 +0000 (+0000) Subject: added compare on rr_lists X-Git-Tag: release-1.1.0~258 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=87b111d8b21bf9d0bb9aa2a60803307d46f0e3ec;p=thirdparty%2Fldns.git added compare on rr_lists added string for NULL error fixed some memory leaks --- diff --git a/error.c b/error.c index 317c9ebc..67b144db 100644 --- a/error.c +++ b/error.c @@ -36,6 +36,7 @@ ldns_lookup_table ldns_error_str[] = { { LDNS_STATUS_ADDRESS_ERR, "Could not start AXFR, because of address error" }, { LDNS_STATUS_UNKNOWN_INET, "Uknown address family" }, { LDNS_STATUS_NOT_IMPL, "This function is not implemented (yet), please notify the developers - or not..." }, + { LDNS_STATUS_NULL, "Supplied value pointer null" }, { LDNS_STATUS_CRYPTO_UNKNOWN_ALGO, "Unknown cryptographic algorithm" }, { LDNS_STATUS_CRYPTO_ALGO_NOT_IMPL, "Cryptographic algorithm not implemented" }, { LDNS_STATUS_CRYPTO_NO_RRSIG, "No DNSSEC signature(s)" }, diff --git a/ldns/error.h b/ldns/error.h index 5a392064..b1e56f2c 100644 --- a/ldns/error.h +++ b/ldns/error.h @@ -40,7 +40,7 @@ enum ldns_enum_status LDNS_STATUS_ADDRESS_ERR, LDNS_STATUS_UNKNOWN_INET, LDNS_STATUS_NOT_IMPL, - LDNS_STATUS_NULL, + LDNS_STATUS_NULL, LDNS_STATUS_CRYPTO_UNKNOWN_ALGO, LDNS_STATUS_CRYPTO_ALGO_NOT_IMPL, LDNS_STATUS_CRYPTO_NO_RRSIG, diff --git a/ldns/rr.h b/ldns/rr.h index cdc3042e..ebbef33c 100644 --- a/ldns/rr.h +++ b/ldns/rr.h @@ -609,6 +609,16 @@ int ldns_rr_compare(const ldns_rr *rr1, const ldns_rr *rr2); */ bool ldns_rr_compare_ds(const ldns_rr *rr1, const ldns_rr *rr2); +/** + * compares two rr listss. + * \param[in] rrl1 the first one + * \param[in] rrl2 the second one + * \return 0 if equal + * -1 if rrl1 comes before rrl2 + * +1 if rrl2 comes before rrl1 + */ +int ldns_rr_list_compare(const ldns_rr_list *rrl1, const ldns_rr_list *rrl2); + /** * calculates the uncompressed size of an RR. * \param[in] r the rr to operate on diff --git a/net.c b/net.c index 5125a679..6cff5d54 100644 --- a/net.c +++ b/net.c @@ -175,6 +175,7 @@ ldns_send(ldns_pkt **result, ldns_resolver *r, const ldns_pkt *query_pkt) } if (all_servers_rtt_inf) { + LDNS_FREE(reply_bytes); return LDNS_STATUS_NO_NAMESERVERS_ERR; } #ifdef HAVE_SSL diff --git a/rr.c b/rr.c index e9c45522..fbb62f45 100644 --- a/rr.c +++ b/rr.c @@ -1265,6 +1265,33 @@ ldns_rr_compare_ds(const ldns_rr *orr1, const ldns_rr *orr2) return result; } +int +ldns_rr_list_compare(const ldns_rr_list *rrl1, const ldns_rr_list *rrl2) +{ + size_t i = 0; + int rr_cmp; + + assert(rrl1 != NULL); + assert(rrl2 != NULL); + + for (i = 0; i < ldns_rr_list_rr_count(rrl1) && i < ldns_rr_list_rr_count(rrl2); i++) { + rr_cmp = ldns_rr_compare(ldns_rr_list_rr(rrl1, i), ldns_rr_list_rr(rrl2, i)); + if (rr_cmp != 0) { + return rr_cmp; + } + } + + if (i == ldns_rr_list_rr_count(rrl1) && + i != ldns_rr_list_rr_count(rrl2)) { + return 1; + } else if (i == ldns_rr_list_rr_count(rrl2) && + i != ldns_rr_list_rr_count(rrl1)) { + return -1; + } else { + return 0; + } +} + size_t ldns_rr_uncompressed_size(const ldns_rr *r) {