hostcache: made all host caches use structs, not pointers

This avoids unnecessary dynamic allocs and as this also removed the last
users of *hash_alloc() and *hash_destroy(), those two functions are now
removed.
This commit is contained in:
Daniel Stenberg
2015-05-12 09:46:53 +02:00
parent d37e0160c2
commit b419e7ae0c
10 changed files with 31 additions and 82 deletions

View File

@@ -294,8 +294,7 @@ struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */
multi->type = CURL_MULTI_HANDLE;
multi->hostcache = Curl_mk_dnscache();
if(!multi->hostcache)
if(Curl_mk_dnscache(&multi->hostcache))
goto error;
if(sh_init(&multi->sockhash, hashsize))
@@ -329,8 +328,7 @@ struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */
error:
Curl_hash_clean(&multi->sockhash);
Curl_hash_destroy(multi->hostcache);
multi->hostcache = NULL;
Curl_hash_clean(&multi->hostcache);
Curl_conncache_destroy(&multi->conn_cache);
Curl_close(multi->closure_handle);
multi->closure_handle = NULL;
@@ -400,7 +398,7 @@ CURLMcode curl_multi_add_handle(CURLM *multi_handle,
easy handle's one is currently not set. */
else if(!data->dns.hostcache ||
(data->dns.hostcachetype == HCACHE_NONE)) {
data->dns.hostcache = multi->hostcache;
data->dns.hostcache = &multi->hostcache;
data->dns.hostcachetype = HCACHE_MULTI;
}
@@ -1861,7 +1859,7 @@ CURLMcode curl_multi_cleanup(CURLM *multi_handle)
sigpipe_ignore(multi->closure_handle, &pipe_st);
restore_pipe = TRUE;
multi->closure_handle->dns.hostcache = multi->hostcache;
multi->closure_handle->dns.hostcache = &multi->hostcache;
Curl_hostcache_clean(multi->closure_handle,
multi->closure_handle->dns.hostcache);
@@ -1891,7 +1889,7 @@ CURLMcode curl_multi_cleanup(CURLM *multi_handle)
data = nextdata;
}
Curl_hash_destroy(multi->hostcache);
Curl_hash_clean(&multi->hostcache);
/* Free the blacklists by setting them to NULL */
Curl_pipeline_set_site_blacklist(NULL, &multi->pipelining_site_bl);