summaryrefslogtreecommitdiff
path: root/lib/conncache.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-12-10 12:54:17 +0100
committerDaniel Stenberg <daniel@haxx.se>2021-12-10 23:16:43 +0100
commit254f7bd78a1ab248329def2cbbbc983e7f6d2495 (patch)
treed1fd479896f6c3a666befa9e57b71252a1d91248 /lib/conncache.c
parente43ad4b47442c99c95f76675a17e608610231871 (diff)
downloadcurl-bagder/hash-lazyalloc.tar.gz
hash: lazy-alloc the table in Curl_hash_add()bagder/hash-lazyalloc
This makes Curl_hash_init() infallible which saves error paths. Closes #8132
Diffstat (limited to 'lib/conncache.c')
-rw-r--r--lib/conncache.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/lib/conncache.c b/lib/conncache.c
index f5ba8ff70..fec1937f0 100644
--- a/lib/conncache.c
+++ b/lib/conncache.c
@@ -113,21 +113,16 @@ static void free_bundle_hash_entry(void *freethis)
int Curl_conncache_init(struct conncache *connc, int size)
{
- int rc;
-
/* allocate a new easy handle to use when closing cached connections */
connc->closure_handle = curl_easy_init();
if(!connc->closure_handle)
return 1; /* bad */
- rc = Curl_hash_init(&connc->hash, size, Curl_hash_str,
- Curl_str_key_compare, free_bundle_hash_entry);
- if(rc)
- Curl_close(&connc->closure_handle);
- else
- connc->closure_handle->state.conn_cache = connc;
+ Curl_hash_init(&connc->hash, size, Curl_hash_str,
+ Curl_str_key_compare, free_bundle_hash_entry);
+ connc->closure_handle->state.conn_cache = connc;
- return rc;
+ return 0; /* good */
}
void Curl_conncache_destroy(struct conncache *connc)