mirror of
https://github.com/curl/curl.git
synced 2026-06-01 22:54:17 +03:00
docs: handle error in curl_global_init* examples
Also: - call cleanup in `curl_global_init_mem()` example. Closes #20866
This commit is contained in:
parent
f6840572c4
commit
df5c6b6f54
2 changed files with 20 additions and 6 deletions
|
|
@ -117,11 +117,16 @@ elapses.
|
|||
~~~c
|
||||
int main(void)
|
||||
{
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
CURLcode result;
|
||||
|
||||
/* use libcurl, then before exiting... */
|
||||
result = curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
|
||||
curl_global_cleanup();
|
||||
if(result == CURLE_OK) {
|
||||
|
||||
/* use libcurl, then before exiting... */
|
||||
|
||||
curl_global_cleanup();
|
||||
}
|
||||
}
|
||||
~~~
|
||||
|
||||
|
|
|
|||
|
|
@ -84,9 +84,18 @@ extern void *calloc_cb(size_t, size_t);
|
|||
|
||||
int main(void)
|
||||
{
|
||||
curl_global_init_mem(CURL_GLOBAL_DEFAULT, malloc_cb,
|
||||
free_cb, realloc_cb,
|
||||
strdup_cb, calloc_cb);
|
||||
CURLcode result;
|
||||
|
||||
result = curl_global_init_mem(CURL_GLOBAL_DEFAULT, malloc_cb,
|
||||
free_cb, realloc_cb,
|
||||
strdup_cb, calloc_cb);
|
||||
|
||||
if(result == CURLE_OK) {
|
||||
|
||||
/* use libcurl, then before exiting... */
|
||||
|
||||
curl_global_cleanup();
|
||||
}
|
||||
}
|
||||
~~~
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue