mirror of
https://github.com/curl/curl.git
synced 2026-08-25 01:23:31 +03:00
examples: improve global init, error checks and returning errors
- add `curl_global_init()` and `curl_global_cleanup()` where missing. - check the result of `curl_global_init()` where missing. - return the last curl error from `main()`. - drop Win32-specific socket initialization in favor of `curl_global_init()`. - rename some outliers to `res` for curl result code. - fix cleanup in some error cases. Inspired by Joshua's report on examples. Closes #19053
This commit is contained in:
parent
3049c8e0a0
commit
4c7507daf9
129 changed files with 990 additions and 485 deletions
|
|
@ -38,8 +38,7 @@ static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
CURLcode res;
|
||||
CURL *curl_handle;
|
||||
static const char *pagefilename = "page.out";
|
||||
FILE *pagefile;
|
||||
|
|
@ -49,7 +48,11 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
res = curl_global_init(CURL_GLOBAL_ALL);
|
||||
if(res) {
|
||||
fprintf(stderr, "Could not init curl\n");
|
||||
return (int)res;
|
||||
}
|
||||
|
||||
/* init the curl session */
|
||||
curl_handle = curl_easy_init();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue