summaryrefslogtreecommitdiff
path: root/lib/conncache.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2013-04-26 22:23:08 +0200
committerDaniel Stenberg <daniel@haxx.se>2013-04-26 22:55:55 +0200
commit642067287931da64e485e402e5e1fa5096abcddd (patch)
treef1c843b46447d2e4607bfe029823352932c4d01f /lib/conncache.c
parentc4067a5678321b1755f6027a5c7510b17e7c16a6 (diff)
downloadcurl-642067287931da64e485e402e5e1fa5096abcddd.tar.gz
curl_easy_init: use less mallocs
By introducing an internal alternative to curl_multi_init() that accepts parameters to set the hash sizes, easy handles will now use tiny socket and connection hash tables since it will only ever add a single easy handle to that multi handle. This decreased the number mallocs in test 40 (which is a rather simple and typical easy interface use case) from 1142 to 138. The maximum amount of memory allocated used went down from 118969 to 78805.
Diffstat (limited to 'lib/conncache.c')
-rw-r--r--lib/conncache.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/conncache.c b/lib/conncache.c
index 530cdc2ec..48271f751 100644
--- a/lib/conncache.c
+++ b/lib/conncache.c
@@ -38,8 +38,6 @@
/* The last #include file should be: */
#include "memdebug.h"
-#define CONNECTION_HASH_SIZE 97
-
static void free_bundle_hash_entry(void *freethis)
{
struct connectbundle *b = (struct connectbundle *) freethis;
@@ -47,7 +45,7 @@ static void free_bundle_hash_entry(void *freethis)
Curl_bundle_destroy(b);
}
-struct conncache *Curl_conncache_init(void)
+struct conncache *Curl_conncache_init(int size)
{
struct conncache *connc;
@@ -55,7 +53,7 @@ struct conncache *Curl_conncache_init(void)
if(!connc)
return NULL;
- connc->hash = Curl_hash_alloc(CONNECTION_HASH_SIZE, Curl_hash_str,
+ connc->hash = Curl_hash_alloc(size, Curl_hash_str,
Curl_str_key_compare, free_bundle_hash_entry);
if(!connc->hash) {