xref: /aosp_15_r20/external/curl/docs/libcurl/curl_easy_cleanup.md (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker---
2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <[email protected]>, et al.
3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl
4*6236dae4SAndroid Build Coastguard WorkerTitle: curl_easy_cleanup
5*6236dae4SAndroid Build Coastguard WorkerSection: 3
6*6236dae4SAndroid Build Coastguard WorkerSource: libcurl
7*6236dae4SAndroid Build Coastguard WorkerSee-also:
8*6236dae4SAndroid Build Coastguard Worker  - curl_easy_duphandle (3)
9*6236dae4SAndroid Build Coastguard Worker  - curl_easy_init (3)
10*6236dae4SAndroid Build Coastguard Worker  - curl_easy_reset (3)
11*6236dae4SAndroid Build Coastguard Worker  - curl_multi_cleanup (3)
12*6236dae4SAndroid Build Coastguard Worker  - curl_multi_remove_handle (3)
13*6236dae4SAndroid Build Coastguard WorkerProtocol:
14*6236dae4SAndroid Build Coastguard Worker  - All
15*6236dae4SAndroid Build Coastguard WorkerAdded-in: 7.1
16*6236dae4SAndroid Build Coastguard Worker---
17*6236dae4SAndroid Build Coastguard Worker
18*6236dae4SAndroid Build Coastguard Worker# NAME
19*6236dae4SAndroid Build Coastguard Worker
20*6236dae4SAndroid Build Coastguard Workercurl_easy_cleanup - free an easy handle
21*6236dae4SAndroid Build Coastguard Worker
22*6236dae4SAndroid Build Coastguard Worker# SYNOPSIS
23*6236dae4SAndroid Build Coastguard Worker
24*6236dae4SAndroid Build Coastguard Worker~~~c
25*6236dae4SAndroid Build Coastguard Worker#include <curl/curl.h>
26*6236dae4SAndroid Build Coastguard Worker
27*6236dae4SAndroid Build Coastguard Workervoid curl_easy_cleanup(CURL *handle);
28*6236dae4SAndroid Build Coastguard Worker~~~
29*6236dae4SAndroid Build Coastguard Worker
30*6236dae4SAndroid Build Coastguard Worker# DESCRIPTION
31*6236dae4SAndroid Build Coastguard Worker
32*6236dae4SAndroid Build Coastguard WorkerThis function is the opposite of curl_easy_init(3). It closes down and frees
33*6236dae4SAndroid Build Coastguard Workerall resources previously associated with this easy handle.
34*6236dae4SAndroid Build Coastguard Worker
35*6236dae4SAndroid Build Coastguard WorkerThis call closes all connections this handle has used and possibly has kept
36*6236dae4SAndroid Build Coastguard Workeropen until now unless the easy handle was attached to a multi handle while
37*6236dae4SAndroid Build Coastguard Workerdoing the transfers. Do not call this function if you intend to transfer more
38*6236dae4SAndroid Build Coastguard Workerfiles, reusing handles is a key to good performance with libcurl.
39*6236dae4SAndroid Build Coastguard Worker
40*6236dae4SAndroid Build Coastguard WorkerOccasionally you may get your progress callback or header callback called from
41*6236dae4SAndroid Build Coastguard Workerwithin curl_easy_cleanup(3) (if previously set for the handle using
42*6236dae4SAndroid Build Coastguard Workercurl_easy_setopt(3)). Like if libcurl decides to shut down the connection and
43*6236dae4SAndroid Build Coastguard Workerthe protocol is of a kind that requires a command/response sequence before
44*6236dae4SAndroid Build Coastguard Workerdisconnect. Examples of such protocols are FTP, POP3 and IMAP.
45*6236dae4SAndroid Build Coastguard Worker
46*6236dae4SAndroid Build Coastguard WorkerAny use of the easy **handle** after this function has been called and have
47*6236dae4SAndroid Build Coastguard Workerreturned, is illegal.
48*6236dae4SAndroid Build Coastguard Worker
49*6236dae4SAndroid Build Coastguard WorkerTo close an easy handle that has been used with the multi interface, make sure
50*6236dae4SAndroid Build Coastguard Workerto first call curl_multi_remove_handle(3) to remove it from the multi handle
51*6236dae4SAndroid Build Coastguard Workerbefore it is closed.
52*6236dae4SAndroid Build Coastguard Worker
53*6236dae4SAndroid Build Coastguard WorkerPassing in a NULL pointer in *handle* makes this function return immediately
54*6236dae4SAndroid Build Coastguard Workerwith no action.
55*6236dae4SAndroid Build Coastguard Worker
56*6236dae4SAndroid Build Coastguard Worker# %PROTOCOLS%
57*6236dae4SAndroid Build Coastguard Worker
58*6236dae4SAndroid Build Coastguard Worker# EXAMPLE
59*6236dae4SAndroid Build Coastguard Worker
60*6236dae4SAndroid Build Coastguard Worker~~~c
61*6236dae4SAndroid Build Coastguard Workerint main(void)
62*6236dae4SAndroid Build Coastguard Worker{
63*6236dae4SAndroid Build Coastguard Worker  CURL *curl = curl_easy_init();
64*6236dae4SAndroid Build Coastguard Worker  if(curl) {
65*6236dae4SAndroid Build Coastguard Worker    CURLcode res;
66*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
67*6236dae4SAndroid Build Coastguard Worker    res = curl_easy_perform(curl);
68*6236dae4SAndroid Build Coastguard Worker    if(res)
69*6236dae4SAndroid Build Coastguard Worker      printf("error: %s\n", curl_easy_strerror(res));
70*6236dae4SAndroid Build Coastguard Worker    curl_easy_cleanup(curl);
71*6236dae4SAndroid Build Coastguard Worker  }
72*6236dae4SAndroid Build Coastguard Worker}
73*6236dae4SAndroid Build Coastguard Worker~~~
74*6236dae4SAndroid Build Coastguard Worker
75*6236dae4SAndroid Build Coastguard Worker# %AVAILABILITY%
76*6236dae4SAndroid Build Coastguard Worker
77*6236dae4SAndroid Build Coastguard Worker# RETURN VALUE
78*6236dae4SAndroid Build Coastguard Worker
79*6236dae4SAndroid Build Coastguard WorkerNone
80