can someone clarify if the memory management (memory manager interface) is meant for scoping.
IMHO it's not and I am willing to make it scopable.

I want to pass scoped memory managers to certain helper functions (xercesc/util/...) and think that this only works in non-exceptional or catch-all circumstances. If those functions (e.g. XMLString::parseInt) throw an exception the scoped memory manager
is passed via ThrowXMLwithMemMgrXXX to the exception during construction.
The exception allocates memory for its internal buffers (message/source file) from that memory manager. If the exception is not caught before the scoped memory manager goes out-of-scope, dereferencing/deallocating the memory during reporting/destruction yields undefined behaviour.

IMHO exceptions should allocate memory for their interal buffers from a static memory manager: Exceptions should query the memory manager interface via a new virtual function for some kind of "global" memory manager instance. In the memory manager default implementation this function just returns the this-pointer to ensure backward compatibility. Scoped memory managers now have the change to override it and delegate requests to a static memory manager, e.g. XMLPlatformUtils::fgMemoryManager.

I think the best approach to make the memory management scopeable is
1. to add a method "virtual MemoryManager* getGlobalMemoryManager()" to the MemoryManager interface that returns the this-pointer 2. to add a call to getGlobalMemoryManager in the XMLException constructor for the memory manager instance passed in as a parameter and save and use the "global" memory manager instance instead of the passed memory manager instance.

does anyone has a different suggestion or can confirm this approach,
so that I can fill out a feature request and provide the patches??

regards
tobias

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to