Search code examples
c++xmldomxercesxerces-c

Is it unsafe or at least bad form to call DOMImplementationRegistry::getDOMImplementation() more than once?


Just wondering if this is safe. The current documentation does not mention having to release() this pointer or that calling it more than once is an error. My own interpretation is that since these things can be obtained as as a list they are created, possibly, by the XMLPlatformUtils::Initialize() method and repeated calling would just return the same pointer value each time.


Solution

  • Judging by the source code, DOMImplementation::getDOMImplementation() calls DOMImplementationImpl::getDOMImplementationImpl() which returns a DOMImplementationImpl object that is initialized when XMLInitializer::initializeDOMImplementationImpl() is called statically by XMLInitializer::initializeStaticData() from XMLPlatformUtils::Initialize().

    So, yes, it would seem to be "safe" to call DOMImplementationRegistry::getDOMImplementation() multiple times since it seems that the method will return the same pointer to the statically created DOMImplementationImpl object each time it is called. Although, I'm not sure why one would want to call DOMImplementationRegistry::getDOMImplementation() multiple times.

    Source code links: