cURL / Mailing Lists / curl-library / Single Mail

curl-library

living without global variables

From: Bryan Henderson <bryanh_at_giraffe-data.com>
Date: Mon, 31 Oct 2005 02:49:50 +0100

I would very much like to be able to use Curl without global variables.
In particular, I'm talking about not doing curl_global_init() and
curl_global_cleanup().

Global variables make it impossible to construct a truly modular program.
If I want to link together two modules into the same program, each using
Curl, Curl cannot be under the covers. They can't both independently
do curl_global_init() and curl_global_cleanup().

I'd like to have an alternative to curl_global_init() that creates and
returns a handle to an object (puts the global variables in
dynamically allocated memory and returns its address). Then the handle
becomes an argument to an alternative version of curl_easy_init() and
curl_multi_init().

Would this be reasonable? I'm willing to code.

I'm not actually very familiar with what the global variables are for.
Might it be more reasonable just to have a version of a Curl easy handle
that is self-contained?

I understand that the Openssl library has the same problem. I'm going to
work on that too.

-- 
Bryan Henderson                                    Phone 408-621-2000
San Jose, California
Received on 2005-10-31