1 | /* Copyright 2002 by the Massachusetts Institute of Technology. |
---|
2 | * |
---|
3 | * Permission to use, copy, modify, and distribute this |
---|
4 | * software and its documentation for any purpose and without |
---|
5 | * fee is hereby granted, provided that the above copyright |
---|
6 | * notice appear in all copies and that both that copyright |
---|
7 | * notice and this permission notice appear in supporting |
---|
8 | * documentation, and that the name of M.I.T. not be used in |
---|
9 | * advertising or publicity pertaining to distribution of the |
---|
10 | * software without specific, written prior permission. |
---|
11 | * M.I.T. makes no representations about the suitability of |
---|
12 | * this software for any purpose. It is provided "as is" |
---|
13 | * without express or implied warranty. |
---|
14 | */ |
---|
15 | |
---|
16 | static const char rcsid[] = "$Id: ares_free_dns_message.c,v 1.1 2002-09-08 23:53:50 ghudson Exp $"; |
---|
17 | |
---|
18 | #include <stdlib.h> |
---|
19 | #include "ares.h" |
---|
20 | #include "ares_private.h" |
---|
21 | |
---|
22 | void ares_free_dns_message(struct ares_dns_message *message) |
---|
23 | { |
---|
24 | ares__free_questions(message->questions, message->qcount); |
---|
25 | ares__free_section(&message->answers); |
---|
26 | ares__free_section(&message->authority); |
---|
27 | ares__free_section(&message->additional); |
---|
28 | free(message); |
---|
29 | } |
---|
30 | |
---|
31 | void ares__free_questions(struct ares_dns_question *questions, int count) |
---|
32 | { |
---|
33 | int i; |
---|
34 | |
---|
35 | for (i = 0; i < count; i++) |
---|
36 | ares__free_question(&questions[i]); |
---|
37 | free(questions); |
---|
38 | } |
---|
39 | |
---|
40 | void ares__free_question(struct ares_dns_question *question) |
---|
41 | { |
---|
42 | free(question->name); |
---|
43 | } |
---|
44 | |
---|
45 | void ares__free_section(struct ares_dns_section *section) |
---|
46 | { |
---|
47 | int i; |
---|
48 | |
---|
49 | for (i = 0; i < section->count; i++) |
---|
50 | ares__free_rr(§ion->records[i]); |
---|
51 | free(section->records); |
---|
52 | } |
---|
53 | |
---|
54 | void ares__free_rr(struct ares_dns_rr *rr) |
---|
55 | { |
---|
56 | free(rr->name); |
---|
57 | free(rr->data); |
---|
58 | } |
---|
59 | |
---|