curl_easy_cleanup.md (1999B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: curl_easy_cleanup 5 Section: 3 6 Source: libcurl 7 See-also: 8 - curl_easy_duphandle (3) 9 - curl_easy_init (3) 10 - curl_easy_reset (3) 11 - curl_multi_cleanup (3) 12 - curl_multi_remove_handle (3) 13 Protocol: 14 - All 15 Added-in: 7.1 16 --- 17 18 # NAME 19 20 curl_easy_cleanup - free an easy handle 21 22 # SYNOPSIS 23 24 ~~~c 25 #include <curl/curl.h> 26 27 void curl_easy_cleanup(CURL *handle); 28 ~~~ 29 30 # DESCRIPTION 31 32 This function is the opposite of curl_easy_init(3). It closes down and frees 33 all resources previously associated with this easy handle. 34 35 This call closes all connections this handle has used and possibly has kept 36 open until now unless the easy handle was attached to a multi handle while 37 doing the transfers. Do not call this function if you intend to transfer more 38 files, reusing handles is a key to good performance with libcurl. 39 40 Occasionally you may get your progress callback or header callback called from 41 within curl_easy_cleanup(3) (if previously set for the handle using 42 curl_easy_setopt(3)). Like if libcurl decides to shut down the connection and 43 the protocol is of a kind that requires a command/response sequence before 44 disconnect. Examples of such protocols are FTP, POP3 and IMAP. 45 46 Any use of the easy **handle** after this function has been called and have 47 returned, is illegal. 48 49 To close an easy handle that has been used with the multi interface, make sure 50 to first call curl_multi_remove_handle(3) to remove it from the multi handle 51 before it is closed. 52 53 Passing in a NULL pointer in *handle* makes this function return immediately 54 with no action. 55 56 # %PROTOCOLS% 57 58 # EXAMPLE 59 60 ~~~c 61 int main(void) 62 { 63 CURL *curl = curl_easy_init(); 64 if(curl) { 65 CURLcode res; 66 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 67 res = curl_easy_perform(curl); 68 if(res) 69 printf("error: %s\n", curl_easy_strerror(res)); 70 curl_easy_cleanup(curl); 71 } 72 } 73 ~~~ 74 75 # %AVAILABILITY% 76 77 # RETURN VALUE 78 79 None