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(ares_channel channel)
31 if (channel->servers) {
32 for (i = 0; i < channel->nservers; i++)
33 ares__close_sockets(channel, &channel->servers[i]);
34 free(channel->servers);
37 if (channel->domains) {
38 for (i = 0; i < channel->ndomains; i++)
39 free(channel->domains[i]);
40 free(channel->domains);
44 free(channel->sortlist);
47 free(channel->lookups);
49 while (channel->queries) {
50 query = channel->queries;
51 channel->queries = query->next;
52 query->callback(query->arg, ARES_EDESTRUCTION, NULL, 0);
55 if (query->skip_server)
56 free(query->skip_server);