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