mirror of
https://github.com/curl/curl.git
synced 2026-08-24 22:23:58 +03:00
hash: lazy-alloc the table in Curl_hash_add()
This makes Curl_hash_init() infallible which saves error paths. Closes #8132
This commit is contained in:
parent
e43ad4b474
commit
254f7bd78a
10 changed files with 78 additions and 83 deletions
|
|
@ -46,19 +46,13 @@ static struct Curl_dns_entry *data_node;
|
|||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
int rc;
|
||||
data = curl_easy_init();
|
||||
if(!data) {
|
||||
curl_global_cleanup();
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
rc = Curl_mk_dnscache(&hp);
|
||||
if(rc) {
|
||||
curl_easy_cleanup(data);
|
||||
curl_global_cleanup();
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
Curl_init_dnscache(&hp);
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2021, 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,8 +38,9 @@ static void mydtor(void *p)
|
|||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return Curl_hash_init(&hash_static, 7, Curl_hash_str,
|
||||
Curl_str_key_compare, mydtor);
|
||||
Curl_hash_init(&hash_static, 7, Curl_hash_str,
|
||||
Curl_str_key_compare, mydtor);
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2015 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 2015 - 2021, 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
|
||||
|
|
@ -39,8 +39,9 @@ static void mydtor(void *p)
|
|||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return Curl_hash_init(&hash_static, slots, Curl_hash_str,
|
||||
Curl_str_key_compare, mydtor);
|
||||
Curl_hash_init(&hash_static, slots, Curl_hash_str,
|
||||
Curl_str_key_compare, mydtor);
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue