From cbae73e1dd95946597ea74ccb580c30f78e3fa73 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 20 Apr 2017 15:10:04 +0200 Subject: llist: no longer uses malloc The 'list element' struct now has to be within the data that is being added to the list. Removes 16.6% (tiny) mallocs from a simple HTTP transfer. (96 => 80) Also removed return codes since the llist functions can't fail now. Test 1300 updated accordingly. Closes #1435 --- lib/hash.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'lib/hash.c') diff --git a/lib/hash.c b/lib/hash.c index b7305a572..6afeaa12c 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -124,17 +124,9 @@ Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p) he = mk_hash_element(key, key_len, p); if(he) { - if(Curl_llist_insert_next(l, l->tail, he)) { - ++h->size; - return p; /* return the new entry */ - } - /* - * Couldn't insert it, destroy the 'he' element and the key again. We - * don't call hash_element_dtor() since that would also call the - * "destructor" for the actual data 'p'. When we fail, we shall not touch - * that data. - */ - free(he); + Curl_llist_insert_next(l, l->tail, he, &he->list); + ++h->size; + return p; /* return the new entry */ } return NULL; /* failure */ -- cgit v1.2.3