void wswcurl_delete(wswcurl_req *req) { if ( (!req) || (!wswcurl_isvalidhandle(req)) ) { return; } if (req->txhead) { curl_slist_free_all(req->txhead); req->txhead = NULL; } if (req->post) { curl_formfree(req->post); req->post = NULL; req->post_last = NULL; } if (req->rxdata) { WFREE(req->rxdata); req->rxdata = NULL; } if (req->filename) { WFREE(req->filename); req->filename = NULL; } #ifndef WSWCURL_TEST_MAIN if (req->filenum >= 0) { FS_FCloseFile(req->filenum); req->filenum = -1; } #else // TODO: IMPLEMENT TEST #endif if (req->curl) { if ( (curlmulti) && (req->status)) curl_multi_remove_handle(curlmulti, req->curl); curl_easy_cleanup(req->curl); req->curl = NULL; } if ( (req->next == NULL) && (req == http_requests) ) { // Last item in list curl_multi_cleanup(curlmulti); curlmulti = NULL; } if (req->url) { WFREE(req->url); } // remove from list if (http_requests == req) http_requests = req->next; if (req->prev) req->prev->next = req->next; if (req->next) req->next->prev = req->prev; WFREE(req); }
void wswcurl_delete(wswcurl_req *req) { if ( (!req) || (!wswcurl_isvalidhandle(req)) ) { return; } // if (req->callback_done && req->active ) // req->callback_done ( req, 0, req->customp ); if (req->txhead) { curl_slist_free_all(req->txhead); req->txhead = NULL; } if (req->post) { curl_formfree(req->post); req->post = NULL; req->post_last = NULL; } if (req->curl) { if (curlmulti && req->status && req->status != WSTATUS_QUEUED) { curl_multi_remove_handle(curlmulti, req->curl); curlmulti_num_handles--; } curl_easy_cleanup(req->curl); req->curl = NULL; } if ( (req->next == NULL) && (req == http_requests) ) { // Last item in list curl_multi_cleanup(curlmulti); curlmulti = NULL; } if (req->url) { WFREE(req->url); } if( req->bhead ) { chained_buffer_t *cb = req->bhead; chained_buffer_t *next = cb->next; while( cb ) { WFREE( cb ); cb = next; if( cb ) next = cb->next; } } // remove from list if (http_requests_hnode == req) http_requests_hnode = req->prev; if (http_requests == req) http_requests = req->next; if (req->prev) req->prev->next = req->next; if (req->next) req->next->prev = req->prev; WFREE(req); }