[gnutls-dev] Re: living without global variables
jas at extundo.com
Fri Dec 23 14:47:27 CET 2005
bryanh at giraffe-data.com (Bryan Henderson) writes:
>>These variables are constant during the lifetime of the application.
> I didn't really mean to refer to those two root pointers as the global
> variables -- the entire tree each points to is the global variable.
The entire tree is constant as well.
> The most serious way that these "variables" change during the lifetime
> of the application is when a piece (module) of the application does a
> gnutls_global_deinit(). That would blow up some other module in the
> same application that happens to be using gnutls.
Yes. gnutls_global_deinit() should not be called if you want to
continue to use the library. No other function modify that variable.
> In case it isn't clear what sort of "module" I'm talking about: I (and
> plenty of others, I'm sure) want to distribute a programming library
> that uses gnutls to provide some of its function. It should be
> possible for my user to be blissfully ignorant of the gnutls stuff
> going on inside the library, which means he doesn't worry about
> initializing and deinitializing the gnutls library. His program may use
> gnutls for its own purposes, and may use some other library that uses
> gnutls under the covers like mine.
> It's common in modern libraries to avoid process-global variables
> completely as a matter of good programming style (it helps not only
> with modularity but thread safety and recursion as well).
I think it would be useful to see exactly what changes you are
thinking of in more detail. Remember that API changes are bad. I'm
not sure exactly what real problem you are having. Without
understanding the problem more, it is difficult to justify API changes
(which if I understood you correctly would be necessary).
More information about the Gnutls-devel