Loading lib/conncache.c +8 −14 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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); } Loading @@ -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; Loading @@ -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 */ Loading Loading @@ -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 */ Loading Loading @@ -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; } Loading lib/conncache.h +2 −2 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2015 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2012 - 2014, Linus Nielsen Feltzing, <linus@haxx.se> * * This software is licensed as described in the file COPYING, which Loading Loading @@ -38,7 +38,7 @@ struct conncache { struct connectbundle { int multiuse; /* supports multi-use */ size_t num_connections; /* Number of connections in the bundle */ struct curl_llist *conn_list; /* The connectdata members of the bundle */ struct curl_llist conn_list; /* The connectdata members of the bundle */ }; int Curl_conncache_init(struct conncache *, int size); Loading lib/ftp.c +8 −7 Original line number Diff line number Diff line Loading @@ -3900,7 +3900,7 @@ static CURLcode wc_statemach(struct connectdata *conn) wildcard->state = CURLWC_CLEAN; return wc_statemach(conn); } if(wildcard->filelist->size == 0) { if(wildcard->filelist.size == 0) { /* no corresponding file */ wildcard->state = CURLWC_CLEAN; return CURLE_REMOTE_FILE_NOT_FOUND; Loading @@ -3911,7 +3911,7 @@ static CURLcode wc_statemach(struct connectdata *conn) case CURLWC_DOWNLOADING: { /* filelist has at least one file, lets get first one */ struct ftp_conn *ftpc = &conn->proto.ftpc; struct curl_fileinfo *finfo = wildcard->filelist->head->ptr; struct curl_fileinfo *finfo = wildcard->filelist.head->ptr; char *tmp_path = aprintf("%s%s", wildcard->path, finfo->filename); if(!tmp_path) Loading @@ -3926,7 +3926,7 @@ static CURLcode wc_statemach(struct connectdata *conn) infof(conn->data, "Wildcard - START of \"%s\"\n", finfo->filename); if(conn->data->set.chunk_bgn) { long userresponse = conn->data->set.chunk_bgn( finfo, wildcard->customptr, (int)wildcard->filelist->size); finfo, wildcard->customptr, (int)wildcard->filelist.size); switch(userresponse) { case CURL_CHUNK_BGN_FUNC_SKIP: infof(conn->data, "Wildcard - \"%s\" skipped by user\n", Loading @@ -3951,9 +3951,9 @@ static CURLcode wc_statemach(struct connectdata *conn) return result; /* we don't need the Curl_fileinfo of first file anymore */ Curl_llist_remove(wildcard->filelist, wildcard->filelist->head, NULL); Curl_llist_remove(&wildcard->filelist, wildcard->filelist.head, NULL); if(wildcard->filelist->size == 0) { /* remains only one file to down. */ if(wildcard->filelist.size == 0) { /* remains only one file to down. */ wildcard->state = CURLWC_CLEAN; /* after that will be ftp_do called once again and no transfer will be done because of CURLWC_CLEAN state */ Loading @@ -3964,8 +3964,8 @@ static CURLcode wc_statemach(struct connectdata *conn) case CURLWC_SKIP: { if(conn->data->set.chunk_end) conn->data->set.chunk_end(conn->data->wildcard.customptr); Curl_llist_remove(wildcard->filelist, wildcard->filelist->head, NULL); wildcard->state = (wildcard->filelist->size == 0) ? Curl_llist_remove(&wildcard->filelist, wildcard->filelist.head, NULL); wildcard->state = (wildcard->filelist.size == 0) ? CURLWC_CLEAN : CURLWC_DOWNLOADING; return wc_statemach(conn); } Loading @@ -3981,6 +3981,7 @@ static CURLcode wc_statemach(struct connectdata *conn) case CURLWC_DONE: case CURLWC_ERROR: case CURLWC_CLEAR: break; } Loading lib/ftplistparser.c +2 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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 Loading Loading @@ -280,7 +280,7 @@ static CURLcode ftp_pl_insert_finfo(struct connectdata *conn, curl_fnmatch_callback compare; struct WildcardData *wc = &conn->data->wildcard; struct ftp_wc_tmpdata *tmpdata = wc->tmp; struct curl_llist *llist = wc->filelist; struct curl_llist *llist = &wc->filelist; struct ftp_parselist_data *parser = tmpdata->parser; bool add = TRUE; Loading lib/hash.c +9 −21 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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 Loading Loading @@ -74,21 +74,10 @@ Curl_hash_init(struct curl_hash *h, h->size = 0; h->slots = slots; h->table = malloc(slots * sizeof(struct curl_llist *)); h->table = malloc(slots * sizeof(struct curl_llist)); if(h->table) { for(i = 0; i < slots; ++i) { h->table[i] = Curl_llist_alloc((curl_llist_dtor) hash_element_dtor); if(!h->table[i]) { while(i--) { Curl_llist_destroy(h->table[i], NULL); h->table[i] = NULL; } free(h->table); h->table = NULL; h->slots = 0; return 1; /* failure */ } } for(i = 0; i < slots; ++i) Curl_llist_init(&h->table[i], (curl_llist_dtor) hash_element_dtor); return 0; /* fine */ } h->slots = 0; Loading Loading @@ -119,7 +108,7 @@ mk_hash_element(const void *key, size_t key_len, const void *p) return he; } #define FETCH_LIST(x,y,z) x->table[x->hash_func(y, z, x->slots)] #define FETCH_LIST(x,y,z) &x->table[x->hash_func(y, z, x->slots)] /* Insert the data in the hash. If there already was a match in the hash, * that data is replaced. Loading Loading @@ -241,8 +230,7 @@ Curl_hash_destroy(struct curl_hash *h) int i; for(i = 0; i < h->slots; ++i) { Curl_llist_destroy(h->table[i], (void *) h); h->table[i] = NULL; Curl_llist_destroy(&h->table[i], (void *) h); } Curl_safefree(h->table); Loading Loading @@ -274,7 +262,7 @@ Curl_hash_clean_with_criterium(struct curl_hash *h, void *user, return; for(i = 0; i < h->slots; ++i) { list = h->table[i]; list = &h->table[i]; le = list->head; /* get first list entry */ while(le) { struct curl_hash_element *he = le->ptr; Loading Loading @@ -333,8 +321,8 @@ Curl_hash_next_element(struct curl_hash_iterator *iter) /* If we have reached the end of the list, find the next one */ if(!iter->current_element) { for(i = iter->slot_index;i < h->slots;i++) { if(h->table[i]->head) { iter->current_element = h->table[i]->head; if(h->table[i].head) { iter->current_element = h->table[i].head; iter->slot_index = i+1; break; } Loading Loading
lib/conncache.c +8 −14 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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); } Loading @@ -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; Loading @@ -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 */ Loading Loading @@ -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 */ Loading Loading @@ -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; } Loading
lib/conncache.h +2 −2 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2015 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2012 - 2014, Linus Nielsen Feltzing, <linus@haxx.se> * * This software is licensed as described in the file COPYING, which Loading Loading @@ -38,7 +38,7 @@ struct conncache { struct connectbundle { int multiuse; /* supports multi-use */ size_t num_connections; /* Number of connections in the bundle */ struct curl_llist *conn_list; /* The connectdata members of the bundle */ struct curl_llist conn_list; /* The connectdata members of the bundle */ }; int Curl_conncache_init(struct conncache *, int size); Loading
lib/ftp.c +8 −7 Original line number Diff line number Diff line Loading @@ -3900,7 +3900,7 @@ static CURLcode wc_statemach(struct connectdata *conn) wildcard->state = CURLWC_CLEAN; return wc_statemach(conn); } if(wildcard->filelist->size == 0) { if(wildcard->filelist.size == 0) { /* no corresponding file */ wildcard->state = CURLWC_CLEAN; return CURLE_REMOTE_FILE_NOT_FOUND; Loading @@ -3911,7 +3911,7 @@ static CURLcode wc_statemach(struct connectdata *conn) case CURLWC_DOWNLOADING: { /* filelist has at least one file, lets get first one */ struct ftp_conn *ftpc = &conn->proto.ftpc; struct curl_fileinfo *finfo = wildcard->filelist->head->ptr; struct curl_fileinfo *finfo = wildcard->filelist.head->ptr; char *tmp_path = aprintf("%s%s", wildcard->path, finfo->filename); if(!tmp_path) Loading @@ -3926,7 +3926,7 @@ static CURLcode wc_statemach(struct connectdata *conn) infof(conn->data, "Wildcard - START of \"%s\"\n", finfo->filename); if(conn->data->set.chunk_bgn) { long userresponse = conn->data->set.chunk_bgn( finfo, wildcard->customptr, (int)wildcard->filelist->size); finfo, wildcard->customptr, (int)wildcard->filelist.size); switch(userresponse) { case CURL_CHUNK_BGN_FUNC_SKIP: infof(conn->data, "Wildcard - \"%s\" skipped by user\n", Loading @@ -3951,9 +3951,9 @@ static CURLcode wc_statemach(struct connectdata *conn) return result; /* we don't need the Curl_fileinfo of first file anymore */ Curl_llist_remove(wildcard->filelist, wildcard->filelist->head, NULL); Curl_llist_remove(&wildcard->filelist, wildcard->filelist.head, NULL); if(wildcard->filelist->size == 0) { /* remains only one file to down. */ if(wildcard->filelist.size == 0) { /* remains only one file to down. */ wildcard->state = CURLWC_CLEAN; /* after that will be ftp_do called once again and no transfer will be done because of CURLWC_CLEAN state */ Loading @@ -3964,8 +3964,8 @@ static CURLcode wc_statemach(struct connectdata *conn) case CURLWC_SKIP: { if(conn->data->set.chunk_end) conn->data->set.chunk_end(conn->data->wildcard.customptr); Curl_llist_remove(wildcard->filelist, wildcard->filelist->head, NULL); wildcard->state = (wildcard->filelist->size == 0) ? Curl_llist_remove(&wildcard->filelist, wildcard->filelist.head, NULL); wildcard->state = (wildcard->filelist.size == 0) ? CURLWC_CLEAN : CURLWC_DOWNLOADING; return wc_statemach(conn); } Loading @@ -3981,6 +3981,7 @@ static CURLcode wc_statemach(struct connectdata *conn) case CURLWC_DONE: case CURLWC_ERROR: case CURLWC_CLEAR: break; } Loading
lib/ftplistparser.c +2 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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 Loading Loading @@ -280,7 +280,7 @@ static CURLcode ftp_pl_insert_finfo(struct connectdata *conn, curl_fnmatch_callback compare; struct WildcardData *wc = &conn->data->wildcard; struct ftp_wc_tmpdata *tmpdata = wc->tmp; struct curl_llist *llist = wc->filelist; struct curl_llist *llist = &wc->filelist; struct ftp_parselist_data *parser = tmpdata->parser; bool add = TRUE; Loading
lib/hash.c +9 −21 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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 Loading Loading @@ -74,21 +74,10 @@ Curl_hash_init(struct curl_hash *h, h->size = 0; h->slots = slots; h->table = malloc(slots * sizeof(struct curl_llist *)); h->table = malloc(slots * sizeof(struct curl_llist)); if(h->table) { for(i = 0; i < slots; ++i) { h->table[i] = Curl_llist_alloc((curl_llist_dtor) hash_element_dtor); if(!h->table[i]) { while(i--) { Curl_llist_destroy(h->table[i], NULL); h->table[i] = NULL; } free(h->table); h->table = NULL; h->slots = 0; return 1; /* failure */ } } for(i = 0; i < slots; ++i) Curl_llist_init(&h->table[i], (curl_llist_dtor) hash_element_dtor); return 0; /* fine */ } h->slots = 0; Loading Loading @@ -119,7 +108,7 @@ mk_hash_element(const void *key, size_t key_len, const void *p) return he; } #define FETCH_LIST(x,y,z) x->table[x->hash_func(y, z, x->slots)] #define FETCH_LIST(x,y,z) &x->table[x->hash_func(y, z, x->slots)] /* Insert the data in the hash. If there already was a match in the hash, * that data is replaced. Loading Loading @@ -241,8 +230,7 @@ Curl_hash_destroy(struct curl_hash *h) int i; for(i = 0; i < h->slots; ++i) { Curl_llist_destroy(h->table[i], (void *) h); h->table[i] = NULL; Curl_llist_destroy(&h->table[i], (void *) h); } Curl_safefree(h->table); Loading Loading @@ -274,7 +262,7 @@ Curl_hash_clean_with_criterium(struct curl_hash *h, void *user, return; for(i = 0; i < h->slots; ++i) { list = h->table[i]; list = &h->table[i]; le = list->head; /* get first list entry */ while(le) { struct curl_hash_element *he = le->ptr; Loading Loading @@ -333,8 +321,8 @@ Curl_hash_next_element(struct curl_hash_iterator *iter) /* If we have reached the end of the list, find the next one */ if(!iter->current_element) { for(i = iter->slot_index;i < h->slots;i++) { if(h->table[i]->head) { iter->current_element = h->table[i]->head; if(h->table[i].head) { iter->current_element = h->table[i].head; iter->slot_index = i+1; break; } Loading