fixed Curl_freeaddrinfo() to only free addrinfo, and added Curl_freednsinfo()
for freeing single dns cache entries
This commit is contained in:
24
lib/hostip.c
24
lib/hostip.c
@@ -88,7 +88,7 @@ static Curl_addrinfo *my_getaddrinfo(struct SessionHandle *data,
|
||||
void Curl_global_host_cache_init(void)
|
||||
{
|
||||
if (!host_cache_initialized) {
|
||||
Curl_hash_init(&hostname_cache, 7, Curl_freeaddrinfo);
|
||||
Curl_hash_init(&hostname_cache, 7, Curl_freednsinfo);
|
||||
host_cache_initialized = 1;
|
||||
}
|
||||
}
|
||||
@@ -287,17 +287,25 @@ struct Curl_dns_entry *Curl_resolv(struct SessionHandle *data,
|
||||
/*
|
||||
* This is a wrapper function for freeing name information in a protocol
|
||||
* independent way. This takes care of using the appropriate underlaying
|
||||
* proper function.
|
||||
* function.
|
||||
*/
|
||||
void Curl_freeaddrinfo(void *freethis)
|
||||
void Curl_freeaddrinfo(Curl_addrinfo *p)
|
||||
{
|
||||
#ifdef ENABLE_IPV6
|
||||
freeaddrinfo(p);
|
||||
#else
|
||||
free(p);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Free a cache dns entry.
|
||||
*/
|
||||
void Curl_freednsinfo(void *freethis)
|
||||
{
|
||||
struct Curl_dns_entry *p = (struct Curl_dns_entry *) freethis;
|
||||
|
||||
#ifdef ENABLE_IPV6
|
||||
freeaddrinfo(p->addr);
|
||||
#else
|
||||
free(p->addr);
|
||||
#endif
|
||||
Curl_freeaddrinfo(p->addr);
|
||||
|
||||
free(p);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user