1curl_easy_cleanup(3) libcurl Manual curl_easy_cleanup(3)
2
3
4
6 curl_easy_cleanup - End a libcurl easy handle
7
9 #include <curl/curl.h>
10
11 void curl_easy_cleanup(CURL *handle);
12
14 This function must be the last function to call for an easy session. It
15 is the opposite of the curl_easy_init(3) function and must be called
16 with the same handle as input that a curl_easy_init(3) call returned.
17
18 This might close all connections this handle has used and possibly has
19 kept open until now - unless it was attached to a multi handle while
20 doing the transfers. Do not call this function if you intend to trans‐
21 fer more files, re-using handles is a key to good performance with
22 libcurl.
23
24 Occasionally you may get your progress callback or header callback
25 called from within curl_easy_cleanup(3) (if previously set for the han‐
26 dle using curl_easy_setopt(3)). Like if libcurl decides to shut down
27 the connection and the protocol is of a kind that requires a com‐
28 mand/response sequence before disconnect. Examples of such protocols
29 are FTP, POP3 and IMAP.
30
31 Any use of the handle after this function has been called and have re‐
32 turned, is illegal. curl_easy_cleanup(3) kills the handle and all mem‐
33 ory associated with it!
34
35 To close an easy handle that has been used with the multi interface,
36 make sure to call curl_multi_remove_handle(3) first to remove it from
37 the multi handle before it is closed.
38
39 Passing in a NULL pointer in handle will make this function return im‐
40 mediately with no action.
41
43 CURL *curl = curl_easy_init();
44 if(curl) {
45 CURLcode res;
46 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
47 res = curl_easy_perform(curl);
48 curl_easy_cleanup(curl);
49 }
50
52 Added in 7.1
53
55 None
56
58 curl_easy_init(3), curl_easy_duphandle(3), curl_easy_reset(3),
59 curl_multi_cleanup(3), curl_multi_remove_handle(3)
60
61
62
63libcurl 7.85.0 May 17, 2022 curl_easy_cleanup(3)