cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: living without global variables

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 31 Oct 2005 20:24:10 +0100 (CET)

On Mon, 31 Oct 2005, Bryan Henderson wrote:

> I looked at the code, and saw several other global variables:

Indeed. I didn't think far enough...

> 3) identity of the memory management functions (this is
> curl_global_init_mem(), which would be nice to use in a modular
> program too).

They are global since they replace memory functions _before_ any malloc etc is
done. But of course there could be a *global_mem() type that uses the malloc()
replacement function itself to alloc the object.

> 4) some kind of idna environment.

Yes, but that could be remade into something else since.

> 5) some kind of Amiga environment.

Right. It looks a little similiar like the windows thing concept-wise.

> 1. Document that you don't have to do curl_global_init() if you aren't using
> OpenSSL, Windows, Amiga, or Idna. (I.e. if you avoid those, you can have a
> modular user of libcurl). Maybe better still -- document that you can skip
> curl_global_init() if you do those initializations that are relevant to your
> program yourself. (As global initializations, they fit better in the caller
> than in Curl anyway).

The flags given to curl_global_init() are made just to allow it to init those
parts that the user/app doesn't initialize by itself.

But I agree, it would be useful to properly document what things libcurl inits
and how you can init those parts instead and then you can call global_init
with a 0 argument.

> 2. Make the sub-global object I described, with the memory allocation
> functions in it.

Yeps, as mentioned above.

> 3. Get a global-variable-free version of OpenSSL and use it with the
> sub-global Curl object.

Is there a global-variable-free version of OpenSSL?

> 4. Do the same for those other global environments (Windows, idna, Amiga).

The windows init is not really a object we can do like this with, AFAIU. The
idna init can be made differently. The Amiga one looks similar to the windows
one and should probably be treated more like the windows one. I guess the very
few amiga users of curl won't make much happen in that area.

I'll appreciate help in all these aress!

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2005-10-31