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

@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, 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
@@ -40,18 +40,19 @@
#include "memdebug.h" /* LAST include file */
static struct SessionHandle *data;
static struct curl_hash *hp;
static struct curl_hash hp;
static char *data_key;
static struct Curl_dns_entry *data_node;
static CURLcode unit_setup( void )
{
int rc;
data = curl_easy_init();
if (!data)
return CURLE_OUT_OF_MEMORY;
hp = Curl_mk_dnscache();
if(!hp) {
rc = Curl_mk_dnscache(&hp);
if(rc) {
curl_easy_cleanup(data);
curl_global_cleanup();
return CURLE_OUT_OF_MEMORY;
@@ -66,7 +67,7 @@ static void unit_stop( void )
free(data_node);
}
free(data_key);
Curl_hash_destroy(hp);
Curl_hash_clean(&hp);
curl_easy_cleanup(data);
curl_global_cleanup();
@@ -129,7 +130,7 @@ UNITTEST_START
key_len = strlen(data_key);
data_node->inuse = 1; /* hash will hold the reference */
nodep = Curl_hash_add(hp, data_key, key_len+1, data_node);
nodep = Curl_hash_add(&hp, data_key, key_len+1, data_node);
abort_unless(nodep, "insertion into hash failed");
/* Freeing will now be done by Curl_hash_destroy */
data_node = NULL;