import: use _cleanup_ attribute for CURL object
This commit is contained in:
parent
1e268f423c
commit
c3e658004a
|
@ -258,9 +258,8 @@ int curl_glue_new(CurlGlue **glue, sd_event *event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int curl_glue_make(CURL **ret, const char *url, void *userdata) {
|
int curl_glue_make(CURL **ret, const char *url, void *userdata) {
|
||||||
|
_cleanup_(curl_easy_cleanupp) CURL *c = NULL;
|
||||||
const char *useragent;
|
const char *useragent;
|
||||||
CURL *c;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
assert(ret);
|
assert(ret);
|
||||||
assert(url);
|
assert(url);
|
||||||
|
@ -271,33 +270,21 @@ int curl_glue_make(CURL **ret, const char *url, void *userdata) {
|
||||||
|
|
||||||
/* curl_easy_setopt(c, CURLOPT_VERBOSE, 1L); */
|
/* curl_easy_setopt(c, CURLOPT_VERBOSE, 1L); */
|
||||||
|
|
||||||
if (curl_easy_setopt(c, CURLOPT_URL, url) != CURLE_OK) {
|
if (curl_easy_setopt(c, CURLOPT_URL, url) != CURLE_OK)
|
||||||
r = -EIO;
|
return -EIO;
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (curl_easy_setopt(c, CURLOPT_PRIVATE, userdata) != CURLE_OK) {
|
if (curl_easy_setopt(c, CURLOPT_PRIVATE, userdata) != CURLE_OK)
|
||||||
r = -EIO;
|
return -EIO;
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
useragent = strjoina(program_invocation_short_name, "/" PACKAGE_VERSION);
|
useragent = strjoina(program_invocation_short_name, "/" PACKAGE_VERSION);
|
||||||
if (curl_easy_setopt(c, CURLOPT_USERAGENT, useragent) != CURLE_OK) {
|
if (curl_easy_setopt(c, CURLOPT_USERAGENT, useragent) != CURLE_OK)
|
||||||
r = -EIO;
|
return -EIO;
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (curl_easy_setopt(c, CURLOPT_FOLLOWLOCATION, 1L) != CURLE_OK) {
|
if (curl_easy_setopt(c, CURLOPT_FOLLOWLOCATION, 1L) != CURLE_OK)
|
||||||
r = -EIO;
|
return -EIO;
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
*ret = c;
|
*ret = c;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
|
||||||
curl_easy_cleanup(c);
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int curl_glue_add(CurlGlue *g, CURL *c) {
|
int curl_glue_add(CurlGlue *g, CURL *c) {
|
||||||
|
|
Loading…
Reference in a new issue