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