summaryrefslogtreecommitdiff
path: root/ares_destroy.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2010-03-05 20:01:47 +0000
committerYang Tse <yangsita@gmail.com>2010-03-05 20:01:47 +0000
commit8fe746fcf2d5b54242a828840ccac630f7a4075a (patch)
tree0ae06cf5be407aea2129f1b47c59c1f433d425db /ares_destroy.c
parent249fc61b8cf1848c4444bef60fc6248930bd0d20 (diff)
downloadc-ares-8fe746fcf2d5b54242a828840ccac630f7a4075a.tar.gz
c-ares-8fe746fcf2d5b54242a828840ccac630f7a4075a.tar.bz2
c-ares-8fe746fcf2d5b54242a828840ccac630f7a4075a.zip
Added IPv6 name servers support
Diffstat (limited to 'ares_destroy.c')
-rw-r--r--ares_destroy.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/ares_destroy.c b/ares_destroy.c
index 2dfb694..d921666 100644
--- a/ares_destroy.c
+++ b/ares_destroy.c
@@ -1,6 +1,7 @@
/* $Id$ */
/* Copyright 1998 by the Massachusetts Institute of Technology.
+ * Copyright (C) 2004-2010 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -25,7 +26,8 @@ void ares_destroy_options(struct ares_options *options)
{
int i;
- free(options->servers);
+ if(options->servers)
+ free(options->servers);
for (i = 0; i < options->ndomains; i++)
free(options->domains[i]);
free(options->domains);
@@ -67,15 +69,7 @@ void ares_destroy(ares_channel channel)
}
#endif
- if (channel->servers) {
- for (i = 0; i < channel->nservers; i++)
- {
- struct server_state *server = &channel->servers[i];
- ares__close_sockets(channel, server);
- assert(ares__is_list_empty(&(server->queries_to_server)));
- }
- free(channel->servers);
- }
+ ares__destroy_servers_state(channel);
if (channel->domains) {
for (i = 0; i < channel->ndomains; i++)
@@ -91,3 +85,22 @@ void ares_destroy(ares_channel channel)
free(channel);
}
+
+void ares__destroy_servers_state(ares_channel channel)
+{
+ struct server_state *server;
+ int i;
+
+ if (channel->servers)
+ {
+ for (i = 0; i < channel->nservers; i++)
+ {
+ server = &channel->servers[i];
+ ares__close_sockets(channel, server);
+ assert(ares__is_list_empty(&server->queries_to_server));
+ }
+ free(channel->servers);
+ channel->servers = NULL;
+ }
+ channel->nservers = -1;
+}