summaryrefslogtreecommitdiff
path: root/lib/share.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2015-05-12 09:46:53 +0200
committerDaniel Stenberg <daniel@haxx.se>2015-05-12 09:46:53 +0200
commitb419e7ae0c9869ac3eb06d529efeb2c6dc1b4bc1 (patch)
tree6938b33aaf767e9006ce881bd707651b10cc946a /lib/share.c
parentd37e0160c2eb22c616ae3ff25c03c3b4711b2a13 (diff)
downloadcurl-b419e7ae0c9869ac3eb06d529efeb2c6dc1b4bc1.tar.gz
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.
Diffstat (limited to 'lib/share.c')
-rw-r--r--lib/share.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/lib/share.c b/lib/share.c
index 3fc53119e..b61a86bc2 100644
--- a/lib/share.c
+++ b/lib/share.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -38,6 +38,11 @@ curl_share_init(void)
if(share)
share->specifier |= (1<<CURL_LOCK_DATA_SHARE);
+ if(Curl_mk_dnscache(&share->hostcache)) {
+ free(share);
+ return NULL;
+ }
+
return share;
}
@@ -67,11 +72,6 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
share->specifier |= (1<<type);
switch( type ) {
case CURL_LOCK_DATA_DNS:
- if(!share->hostcache) {
- share->hostcache = Curl_mk_dnscache();
- if(!share->hostcache)
- res = CURLSHE_NOMEM;
- }
break;
case CURL_LOCK_DATA_COOKIE:
@@ -115,10 +115,6 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
share->specifier &= ~(1<<type);
switch( type ) {
case CURL_LOCK_DATA_DNS:
- if(share->hostcache) {
- Curl_hash_destroy(share->hostcache);
- share->hostcache = NULL;
- }
break;
case CURL_LOCK_DATA_COOKIE:
@@ -192,10 +188,7 @@ curl_share_cleanup(CURLSH *sh)
return CURLSHE_IN_USE;
}
- if(share->hostcache) {
- Curl_hash_destroy(share->hostcache);
- share->hostcache = NULL;
- }
+ Curl_hash_clean(&share->hostcache);
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
Curl_cookie_cleanup(share->cookies);