From 2ae18059f986154efe06fe7fda92a1bb53cca50a Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Wed, 9 Mar 2016 01:02:47 +0100 Subject: 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. --- dbfp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'dbfp.c') 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); } -- cgit v1.2.1