curl-library
Re: living without global variables
Date: Mon, 31 Oct 2005 08:41:46 +0100 (CET)
On Mon, 31 Oct 2005, Bryan Henderson wrote:
> 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().
I would too!
> 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.
There is basically two reasons for curl_global_init/cleanup:
1) OpenSSL's use of globals
2) Windows' winsock initialization requirements that aren't really globals
but that I believe good apps should only do once.
There are no globals in libcurl itself that requires this setup.
-- Commercial curl and libcurl Technical Support: http://haxx.se/curl.htmlReceived on 2005-10-31