From: Jelte Jansen Date: Wed, 15 Dec 2004 11:27:18 +0000 (+0000) Subject: initial ldns_packet_free() X-Git-Tag: release-0.50~680 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea2f464fd06ef041b1a3e04a7d92cbae5a0352e2;p=thirdparty%2Fldns.git initial ldns_packet_free() --- diff --git a/ldns/packet.h b/ldns/packet.h index 75135afe..5847a9fa 100644 --- a/ldns/packet.h +++ b/ldns/packet.h @@ -112,6 +112,13 @@ void packet_set_arcount(ldns_packet_type *, uint16_t); */ ldns_packet_type *ldns_packet_new(); +/** + * Frees the packet structure and all data that it contains + * + * @param packet The packet structure to free + */ +void ldns_packet_free(ldns_packet_type *packet); + /** * Converts the data on the uint8_t bytearray (in wire format) to a DNS packet * diff --git a/packet.c b/packet.c index d0b36aa0..9318d646 100644 --- a/packet.c +++ b/packet.c @@ -328,6 +328,28 @@ ldns_packet_new() return packet; } +void +ldns_packet_free(ldns_packet_type *packet) +{ + FREE(packet->_header); + if (packet->_question) { + /*ldns_rrset_destroy(packet->_question);*/ + } + if (packet->_answer) { + /*ldns_rrset_destroy(packet->_answer);*/ + FREE(packet->_answer); + } + if (packet->_authority) { + /*ldns_rrset_destroy(packet->_authority);*/ + FREE(packet->_authority); + } + if (packet->_additional) { + /*ldns_rrset_destroy(packet->_additional);*/ + FREE(packet->_authority); + } + FREE(packet); +} + static size_t ldns_wire2packet_header(ldns_packet_type *packet, const uint8_t *wire, diff --git a/run-test0.c b/run-test0.c index bcc3d199..c3decc23 100644 --- a/run-test0.c +++ b/run-test0.c @@ -48,5 +48,7 @@ main(void) printf("ancount: %d\n",(int) packet_ancount(packet)); printf("nscount: %d\n",(int) packet_nscount(packet)); printf("arcount: %d\n",(int) packet_arcount(packet)); + + ldns_packet_free(packet); return 0; }