3 /* Copyright 1998 by the Massachusetts Institute of Technology.
5 * Permission to use, copy, modify, and distribute this
6 * software and its documentation for any purpose and without
7 * fee is hereby granted, provided that the above copyright
8 * notice appear in all copies and that both that copyright
9 * notice and this permission notice appear in supporting
10 * documentation, and that the name of M.I.T. not be used in
11 * advertising or publicity pertaining to distribution of the
12 * software without specific, written prior permission.
13 * M.I.T. makes no representations about the suitability of
14 * this software for any purpose. It is provided "as is"
15 * without express or implied warranty.
21 #include "ares_private.h"
23 void ares_destroy_options(struct ares_options *options)
27 free(options->servers);
28 for (i = 0; i < options->ndomains; i++)
29 free(options->domains[i]);
30 free(options->domains);
32 free(options->sortlist);
33 free(options->lookups);
36 void ares_destroy(ares_channel channel)
44 if (channel->servers) {
45 for (i = 0; i < channel->nservers; i++)
46 ares__close_sockets(channel, &channel->servers[i]);
47 free(channel->servers);
50 if (channel->domains) {
51 for (i = 0; i < channel->ndomains; i++)
52 free(channel->domains[i]);
53 free(channel->domains);
57 free(channel->sortlist);
60 free(channel->lookups);
62 while (channel->queries) {
63 query = channel->queries;
64 channel->queries = query->next;
65 query->callback(query->arg, ARES_EDESTRUCTION, NULL, 0);
68 if (query->server_info)
69 free(query->server_info);