• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: curl_global_cleanup
5Section: 3
6Source: libcurl
7See-also:
8  - curl_global_init (3)
9  - libcurl (3)
10  - libcurl-thread (3)
11Protocol:
12  - All
13---
14
15# NAME
16
17curl_global_cleanup - global libcurl cleanup
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24void curl_global_cleanup(void);
25~~~
26
27# DESCRIPTION
28
29This function releases resources acquired by curl_global_init(3).
30
31You should call curl_global_cleanup(3) once for each call you make to
32curl_global_init(3), after you are done using libcurl.
33
34This function is thread-safe since libcurl 7.84.0 if
35curl_version_info(3) has the CURL_VERSION_THREADSAFE feature bit set
36(most platforms).
37
38If this is not thread-safe, you must not call this function when any other
39thread in the program (i.e. a thread sharing the same memory) is running.
40This does not just mean no other thread that is using libcurl. Because
41curl_global_cleanup(3) calls functions of other libraries that are
42similarly thread unsafe, it could conflict with any other thread that uses
43these other libraries.
44
45See the description in libcurl(3) of global environment requirements for
46details of how to use this function.
47
48# CAUTION
49
50curl_global_cleanup(3) does not block waiting for any libcurl-created
51threads to terminate (such as threads used for name resolving). If a module
52containing libcurl is dynamically unloaded while libcurl-created threads are
53still running then your program may crash or other corruption may occur. We
54recommend you do not run libcurl from any module that may be unloaded
55dynamically. This behavior may be addressed in the future.
56
57libcurl may not be able to fully clean up after multi-threaded OpenSSL
58depending on how OpenSSL was built and loaded as a library. It is possible in
59some rare circumstances a memory leak could occur unless you implement your own
60OpenSSL thread cleanup. Refer to libcurl-thread(3).
61
62# EXAMPLE
63
64~~~c
65int main(void)
66{
67  curl_global_init(CURL_GLOBAL_DEFAULT);
68
69  /* use libcurl, then before exiting... */
70
71  curl_global_cleanup();
72}
73~~~
74
75# AVAILABILITY
76
77Added in 7.8
78
79# RETURN VALUE
80
81None
82