aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <me@robin-krahl.de>2016-03-09 01:02:47 +0100
committerRobin Krahl <me@robin-krahl.de>2016-03-09 01:02:47 +0100
commit2ae18059f986154efe06fe7fda92a1bb53cca50a (patch)
treeeb8e7c7368d24d7feb23a1a83f12cd7ae34a4861
parent0f93a7e3516b326b709b3f669f1ca68e306dd3e9 (diff)
downloaddbfp-2ae18059f986154efe06fe7fda92a1bb53cca50a.tar.gz
dbfp-2ae18059f986154efe06fe7fda92a1bb53cca50a.tar.bz2
dbfp: init and cleanup curl in dbfp_init and dbfp_close
dbfp_query_location_name will not be the only function that needs curl, but it is not necessary to initialize and cleanup curl more than once.
-rw-r--r--dbfp.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/dbfp.c b/dbfp.c
index 2089f78..d822f20 100644
--- a/dbfp.c
+++ b/dbfp.c
@@ -45,6 +45,8 @@ int dbfp_init(struct dbfp *dbfp, char *key)
if (!dbfp->key)
return ENOMEM;
+ curl_global_init(CURL_GLOBAL_ALL ^ CURL_GLOBAL_SSL);
+
return 0;
}
@@ -53,6 +55,8 @@ void dbfp_close(struct dbfp *dbfp)
if (!dbfp)
return;
+ curl_global_cleanup();
+
free(dbfp->key);
}
@@ -144,7 +148,6 @@ static void dbfp_request(struct dbfp *dbfp, char *service, char *query,
if (status->run_error)
goto cleanup;
- curl_global_init(CURL_GLOBAL_ALL ^ CURL_GLOBAL_SSL);
curl = curl_easy_init();
if (!curl) {
status->error = 1;
@@ -165,7 +168,6 @@ static void dbfp_request(struct dbfp *dbfp, char *service, char *query,
cleanup:
if (curl)
curl_easy_cleanup(curl);
- curl_global_cleanup();
free(url);
}