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