00001 /* Copyright 1998 by the Massachusetts Institute of Technology. 00002 * 00003 * Permission to use, copy, modify, and distribute this 00004 * software and its documentation for any purpose and without 00005 * fee is hereby granted, provided that the above copyright 00006 * notice appear in all copies and that both that copyright 00007 * notice and this permission notice appear in supporting 00008 * documentation, and that the name of M.I.T. not be used in 00009 * advertising or publicity pertaining to distribution of the 00010 * software without specific, written prior permission. 00011 * M.I.T. makes no representations about the suitability of 00012 * this software for any purpose. It is provided "as is" 00013 * without express or implied warranty. 00014 * 00015 * CHANGELOG: this file has been modified by Sergio Perez Alcañiz <serpeal@disca.upv.es> 00016 * Departamento de Informática de Sistemas y Computadores 00017 * Universidad Politécnica de Valencia 00018 * Valencia (Spain) 00019 * Date: April 2003 00020 * 00021 */ 00022 00023 #include "ares_private.h" 00024 00025 void ares_destroy(ares_channel channel) 00026 { 00027 int i; 00028 struct query *query; 00029 00030 for (i = 0; i < channel->nservers; i++) 00031 ares__close_sockets(&channel->servers[i]); 00032 free(channel->servers); 00033 for (i = 0; i < channel->ndomains; i++) 00034 free(channel->domains[i]); 00035 free(channel->domains); 00036 free(channel->sortlist); 00037 free(channel->lookups); 00038 while (channel->queries) 00039 { 00040 query = channel->queries; 00041 channel->queries = query->next; 00042 query->callback(query->arg, ARES_EDESTRUCTION, NULL, 0); 00043 free(query->tcpbuf); 00044 free(query->skip_server); 00045 free(query); 00046 } 00047 free(channel); 00048 }