]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
initial ldns_packet_free()
authorJelte Jansen <jeltejan@NLnetLabs.nl>
Wed, 15 Dec 2004 11:27:18 +0000 (11:27 +0000)
committerJelte Jansen <jeltejan@NLnetLabs.nl>
Wed, 15 Dec 2004 11:27:18 +0000 (11:27 +0000)
ldns/packet.h
packet.c
run-test0.c

index 75135afe533011f90b0693ae5d2b390add8f7a04..5847a9fa17c811fb6a6d32ad0121cc8ad7412ce7 100644 (file)
@@ -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
  *
index d0b36aa0bdcdeda9d7684b5f6dc8c9b6653cbd35..9318d646bf24f4dad45425a5d7b22a633d1974e2 100644 (file)
--- 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,
index bcc3d199e88f3edb18298754c0a7cac001b60230..c3decc233a1556255fccafd058bc857ec763beaf 100644 (file)
@@ -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;
 }