summaryrefslogtreecommitdiff
path: root/lib/conncache.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2017-04-03 10:32:43 +0200
committerDaniel Stenberg <daniel@haxx.se>2017-04-04 15:27:45 +0200
commite60fe20fdf94e829ba5fce33f7a9d6c281149f7d (patch)
treefbf6694a4d5eda73e885c8e6777abd663f73b53c /lib/conncache.c
parenta68ca63d7313dcc266f92108b2694d43b0afeba7 (diff)
downloadcurl-e60fe20fdf94e829ba5fce33f7a9d6c281149f7d.tar.gz
llist: replace Curl_llist_alloc with Curl_llist_init
No longer allocate the curl_llist head struct for lists separately. Removes 17 (15%) tiny allocations in a normal "curl localhost" invoke. closes #1381
Diffstat (limited to 'lib/conncache.c')
-rw-r--r--lib/conncache.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/lib/conncache.c b/lib/conncache.c
index 7143ff83a..0590ec631 100644
--- a/lib/conncache.c
+++ b/lib/conncache.c
@@ -56,11 +56,7 @@ static CURLcode bundle_create(struct Curl_easy *data,
(*cb_ptr)->num_connections = 0;
(*cb_ptr)->multiuse = BUNDLE_UNKNOWN;
- (*cb_ptr)->conn_list = Curl_llist_alloc((curl_llist_dtor) conn_llist_dtor);
- if(!(*cb_ptr)->conn_list) {
- Curl_safefree(*cb_ptr);
- return CURLE_OUT_OF_MEMORY;
- }
+ Curl_llist_init(&(*cb_ptr)->conn_list, (curl_llist_dtor) conn_llist_dtor);
return CURLE_OK;
}
@@ -69,10 +65,8 @@ static void bundle_destroy(struct connectbundle *cb_ptr)
if(!cb_ptr)
return;
- if(cb_ptr->conn_list) {
- Curl_llist_destroy(cb_ptr->conn_list, NULL);
- cb_ptr->conn_list = NULL;
- }
+ Curl_llist_destroy(&cb_ptr->conn_list, NULL);
+
free(cb_ptr);
}
@@ -80,7 +74,7 @@ static void bundle_destroy(struct connectbundle *cb_ptr)
static CURLcode bundle_add_conn(struct connectbundle *cb_ptr,
struct connectdata *conn)
{
- if(!Curl_llist_insert_next(cb_ptr->conn_list, cb_ptr->conn_list->tail, conn))
+ if(!Curl_llist_insert_next(&cb_ptr->conn_list, cb_ptr->conn_list.tail, conn))
return CURLE_OUT_OF_MEMORY;
conn->bundle = cb_ptr;
@@ -95,10 +89,10 @@ static int bundle_remove_conn(struct connectbundle *cb_ptr,
{
struct curl_llist_element *curr;
- curr = cb_ptr->conn_list->head;
+ curr = cb_ptr->conn_list.head;
while(curr) {
if(curr->ptr == conn) {
- Curl_llist_remove(cb_ptr->conn_list, curr, NULL);
+ Curl_llist_remove(&cb_ptr->conn_list, curr, NULL);
cb_ptr->num_connections--;
conn->bundle = NULL;
return 1; /* we removed a handle */
@@ -289,7 +283,7 @@ void Curl_conncache_foreach(struct conncache *connc,
bundle = he->ptr;
he = Curl_hash_next_element(&iter);
- curr = bundle->conn_list->head;
+ curr = bundle->conn_list.head;
while(curr) {
/* Yes, we need to update curr before calling func(), because func()
might decide to remove the connection */
@@ -318,7 +312,7 @@ Curl_conncache_find_first_connection(struct conncache *connc)
struct curl_llist_element *curr;
bundle = he->ptr;
- curr = bundle->conn_list->head;
+ curr = bundle->conn_list.head;
if(curr) {
return curr->ptr;
}