mirror of
https://github.com/curl/curl.git
synced 2026-07-24 11:17:22 +03:00
examples: check more errors, fix cleanups, scope variables
Inspired by Joshua's report on examples. Closes #19055
This commit is contained in:
parent
61dcb56743
commit
64ed2ea196
42 changed files with 874 additions and 785 deletions
|
|
@ -34,8 +34,7 @@
|
|||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
|
||||
CURL *curl = NULL;
|
||||
CURLU *urlp;
|
||||
CURLUcode uc;
|
||||
|
||||
|
|
@ -43,9 +42,6 @@ int main(void)
|
|||
if(res)
|
||||
return (int)res;
|
||||
|
||||
/* get a curl handle */
|
||||
curl = curl_easy_init();
|
||||
|
||||
/* init Curl URL */
|
||||
urlp = curl_url();
|
||||
uc = curl_url_set(urlp, CURLUPART_URL,
|
||||
|
|
@ -56,6 +52,8 @@ int main(void)
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
/* get a curl handle */
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* set urlp to use as working URL */
|
||||
curl_easy_setopt(curl, CURLOPT_CURLU, urlp);
|
||||
|
|
@ -69,8 +67,6 @@ int main(void)
|
|||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue