[libxml++] Global initialization code



Hi,

libxml++ uses global initialization code like this:

Document::Init::Init()
{
   xmlInitParser(); //Not always necessary, but necessary for thread safety.
   xmlRegisterNodeDefault(on_libxml_construct);
   xmlDeregisterNodeDefault(on_libxml_destruct);
   xmlThrDefRegisterNodeDefault(on_libxml_construct);
   xmlThrDefDeregisterNodeDefault(on_libxml_destruct);
}

Document::Init Document::init_;

We use PHP as apache module and have another module linking libxml++.
The above piece of code totally breaks PHP's XML parser
just by loading the second module.

Changing the code is not easy as it would break existing applications.
One possible solution would be to add a check to every constructor if the 
library was already initialized. On the destruction of the last libxml++ 
class if would have to be uninitialized.

A more clean way would be to have an init()/deinit() function.
Perhaps the use of this mode could be a compile time option?

Please let me know what you think about this.

Cheers,
Thomas




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]