docs: handle error in `curl_global_init*` examples
No binary (build failed)
—
(log yok)
| @@ -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(); |
| + | } |
| } | |
| ~~~ | |