diff --git a/src/xercesc/dom/deprecated/DOMParser.cpp b/src/xercesc/dom/deprecated/DOMParser.cpp index 42f3b62cb42a653f9596779dd97fd20c72169aef..b00a86544fa83976e4d23f5b95caf11a2bd7d224 100644 --- a/src/xercesc/dom/deprecated/DOMParser.cpp +++ b/src/xercesc/dom/deprecated/DOMParser.cpp @@ -96,6 +96,7 @@ #include <xercesc/validators/common/ContentSpecNode.hpp> #include <xercesc/validators/DTD/DTDAttDefList.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -127,6 +128,10 @@ DOMParser::DOMParser( XMLValidator* const valToAdopt { initialize(); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); @@ -429,7 +434,10 @@ void DOMParser::parse(const InputSource& source) fScanner->scanDocument(source); fParseInProgress = false; } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { fParseInProgress = false; @@ -449,7 +457,10 @@ void DOMParser::parse(const XMLCh* const systemId) fScanner->scanDocument(systemId); fParseInProgress = false; } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { fParseInProgress = false; @@ -469,7 +480,10 @@ void DOMParser::parse(const char* const systemId) fScanner->scanDocument(systemId); fParseInProgress = false; } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { fParseInProgress = false; @@ -1363,8 +1377,10 @@ Grammar* DOMParser::loadGrammar(const char* const systemId, grammar = fScanner->loadGrammar(systemId, grammarType, toCache); fParseInProgress = false; } - - catch(...) + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { fParseInProgress = false; throw; @@ -1388,7 +1404,10 @@ Grammar* DOMParser::loadGrammar(const XMLCh* const systemId, grammar = fScanner->loadGrammar(systemId, grammarType, toCache); fParseInProgress = false; } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { fParseInProgress = false; @@ -1413,7 +1432,10 @@ Grammar* DOMParser::loadGrammar(const InputSource& source, grammar = fScanner->loadGrammar(source, grammarType, toCache); fParseInProgress = false; } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { fParseInProgress = false; diff --git a/src/xercesc/dom/deprecated/DOMString.cpp b/src/xercesc/dom/deprecated/DOMString.cpp index 7dbc7709af3170fef9e7ad946b91335a39dcbc54..ad3d8ddbf1380984e8ab540e4be09240b875bfb4 100644 --- a/src/xercesc/dom/deprecated/DOMString.cpp +++ b/src/xercesc/dom/deprecated/DOMString.cpp @@ -173,18 +173,10 @@ DOMStringData *DOMStringData::allocateBuffer(unsigned int length) + length*sizeof(XMLCh); // extra elem because of stub // array in DOMStringData struct. DOMStringData *buf = 0; - try { - buf = (DOMStringData *) XMLPlatformUtils::fgMemoryManager->allocate + buf = (DOMStringData *) XMLPlatformUtils::fgMemoryManager->allocate ( sizeToAllocate * sizeof(char) );//new char[sizeToAllocate]; - } - catch (...) { - ThrowXML(RuntimeException, XMLExcepts::Out_Of_Memory); - } - if (!buf) - ThrowXML(RuntimeException, XMLExcepts::Out_Of_Memory); - XMLPlatformUtils::atomicIncrement(DOMString::gLiveStringDataCount); XMLPlatformUtils::atomicIncrement(DOMString::gTotalStringDataCount); buf->fBufferLength = length; @@ -1227,3 +1219,4 @@ static void reinitDomMutex() XERCES_CPP_NAMESPACE_END + \ No newline at end of file diff --git a/src/xercesc/dom/impl/DOMDocumentImpl.cpp b/src/xercesc/dom/impl/DOMDocumentImpl.cpp index e2eda341e9ddef4dd730a3519f059af6820d5e07..41f701dbe93c6585ff3ffa7594ddbc70d8c3f9dd 100644 --- a/src/xercesc/dom/impl/DOMDocumentImpl.cpp +++ b/src/xercesc/dom/impl/DOMDocumentImpl.cpp @@ -85,6 +85,7 @@ #include <xercesc/dom/DOMImplementation.hpp> #include <xercesc/util/XMLChar.hpp> #include <xercesc/framework/MemoryManager.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -170,6 +171,10 @@ DOMDocumentImpl::DOMDocumentImpl(const XMLCh *fNamespaceURI, else if (fNamespaceURI) throw DOMException(DOMException::NAMESPACE_ERR, 0); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { this->deleteHeap(); throw; @@ -543,6 +548,10 @@ DOMNode* DOMDocumentImpl::replaceChild(DOMNode *newChild, DOMNode *oldChild) { else return removeChild(oldChild); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { fDocType = tempDocType; fDocElement = tempDocElement; @@ -841,16 +850,9 @@ void * DOMDocumentImpl::allocate(size_t amount) size_t sizeOfHeader = XMLPlatformUtils::alignPointerForNewBlockAllocation(sizeof(void *)); // Try to allocate the block - void* newBlock = 0; - try { - newBlock = fMemoryManager->allocate((sizeOfHeader + amount) * sizeof(char)); //new char[amount + sizeOfHeader]; - } - catch (...) { - ThrowXML(RuntimeException, XMLExcepts::Out_Of_Memory); - } - if (!newBlock) - ThrowXML(RuntimeException, XMLExcepts::Out_Of_Memory); - + void* newBlock; + newBlock = fMemoryManager->allocate((sizeOfHeader + amount) * sizeof(char)); //new char[amount + sizeOfHeader]; + // Link it into the list beyond current block, as current block // is still being subdivided. If there is no current block // then track that we have no bytes to further divide. @@ -880,16 +882,9 @@ void * DOMDocumentImpl::allocate(size_t amount) size_t sizeOfHeader = XMLPlatformUtils::alignPointerForNewBlockAllocation(sizeof(void *)); // Get a new block from the system allocator. - void* newBlock = 0; - try { - newBlock = fMemoryManager->allocate(kHeapAllocSize * sizeof(char)); //new char[kHeapAllocSize]; - } - catch (...) { - ThrowXML(RuntimeException, XMLExcepts::Out_Of_Memory); - } - if (!newBlock) - ThrowXML(RuntimeException, XMLExcepts::Out_Of_Memory); - + void* newBlock; + newBlock = fMemoryManager->allocate(kHeapAllocSize * sizeof(char)); //new char[kHeapAllocSize]; + *(void **)newBlock = fCurrentBlock; fCurrentBlock = newBlock; fFreePtr = (char *)newBlock + sizeOfHeader; @@ -1408,3 +1403,4 @@ void * DOMDocumentImpl::allocate(size_t amount, NodeObjectType type) } XERCES_CPP_NAMESPACE_END + \ No newline at end of file diff --git a/src/xercesc/dom/impl/DOMElementImpl.cpp b/src/xercesc/dom/impl/DOMElementImpl.cpp index af44c83a729d0476723ec97b9ceaf3557a428574..b4f95a63c347238c8f4d51f0f831ddce48d6be19 100644 --- a/src/xercesc/dom/impl/DOMElementImpl.cpp +++ b/src/xercesc/dom/impl/DOMElementImpl.cpp @@ -78,6 +78,7 @@ #include "DOMDeepNodeListImpl.hpp" #include "DOMDocumentTypeImpl.hpp" #include "DOMNamedNodeMapImpl.hpp" +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -540,6 +541,10 @@ const XMLCh* DOMElementImpl::getBaseURI() const XMLUri temp2(&temp, uri, ((DOMDocumentImpl *)this->getOwnerDocument())->getMemoryManager()); uri = ((DOMDocumentImpl *)this->getOwnerDocument())->cloneString(temp2.getUriText()); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...){ // REVISIT: what should happen in this case? return 0; diff --git a/src/xercesc/dom/impl/DOMElementNSImpl.cpp b/src/xercesc/dom/impl/DOMElementNSImpl.cpp index 7cd46d6914e4b051e072917a8ced684a7ed42ac5..64a385f646637c51b9f7886d50cdc8cf29a57c20 100644 --- a/src/xercesc/dom/impl/DOMElementNSImpl.cpp +++ b/src/xercesc/dom/impl/DOMElementNSImpl.cpp @@ -63,6 +63,7 @@ #include "DOMDocumentImpl.hpp" #include <xercesc/dom/DOMException.hpp> #include <xercesc/util/XMLUri.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -131,6 +132,10 @@ const XMLCh* DOMElementNSImpl::getBaseURI() const XMLUri temp2(&temp, uri, ((DOMDocumentImpl *)this->getOwnerDocument())->getMemoryManager()); uri = ((DOMDocumentImpl *)this->getOwnerDocument())->cloneString(temp2.getUriText()); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...){ // REVISIT: what should happen in this case? return 0; diff --git a/src/xercesc/dom/impl/DOMWriterImpl.cpp b/src/xercesc/dom/impl/DOMWriterImpl.cpp index ddde7813e8378baa102c3a9f63c14c031a14a8a5..b3b4d0b83a8a63c60e46b05d0e78dcbb5d4fa05a 100644 --- a/src/xercesc/dom/impl/DOMWriterImpl.cpp +++ b/src/xercesc/dom/impl/DOMWriterImpl.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.42 2003/10/01 16:32:37 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.41 2003/08/14 16:31:13 gareth * Method added to allow serilization of custom nodes from derived classes. * @@ -203,7 +206,7 @@ #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/XMLMsgLoader.hpp> #include <xercesc/dom/StDOMNode.hpp> - +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -639,7 +642,10 @@ bool DOMWriterImpl::writeNode(XMLFormatTarget* const destination destination->flush(); return false; } - + catch(const OutOfMemoryException&) + { + throw; + } // // DOMSystemException // This exception will be raised in response to any sort of IO or system @@ -680,6 +686,10 @@ XMLCh* DOMWriterImpl::writeToString(const DOMNode &nodeToWrite) { retVal = writeNode(&destination, nodeToWrite); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { // diff --git a/src/xercesc/framework/XMLAttDef.cpp b/src/xercesc/framework/XMLAttDef.cpp index 49de355cad8dae98314df5904e5926b24981d299..aedffb8801a5b328544a91a528ebfbe5dbabcf11 100644 --- a/src/xercesc/framework/XMLAttDef.cpp +++ b/src/xercesc/framework/XMLAttDef.cpp @@ -65,6 +65,7 @@ #include <xercesc/framework/XMLAttDef.hpp> #include <xercesc/util/ArrayIndexOutOfBoundsException.hpp> #include <xercesc/util/XMLUni.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -188,6 +189,10 @@ XMLAttDef::XMLAttDef( const XMLCh* const attrValue fValue = XMLString::replicate(attrValue, fMemoryManager); fEnumeration = XMLString::replicate(enumValues, fMemoryManager); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); diff --git a/src/xercesc/framework/XMLAttr.cpp b/src/xercesc/framework/XMLAttr.cpp index 79aa475005fbbb9440647fad46522fa1d7b75659..37bac679743799e9e1812b3c86320256cb78fe08 100644 --- a/src/xercesc/framework/XMLAttr.cpp +++ b/src/xercesc/framework/XMLAttr.cpp @@ -64,6 +64,7 @@ // --------------------------------------------------------------------------- #include <xercesc/framework/XMLAttr.hpp> #include <xercesc/framework/MemoryManager.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -106,6 +107,10 @@ XMLAttr::XMLAttr( const unsigned int uriId fAttName = new (fMemoryManager) QName(attrPrefix, attrName, uriId, fMemoryManager); setValue(attrValue); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); @@ -133,6 +138,10 @@ XMLAttr::XMLAttr( const unsigned int uriId fAttName = new (fMemoryManager) QName(rawName, uriId, fMemoryManager); setValue(attrValue); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); diff --git a/src/xercesc/framework/XMLEntityDecl.cpp b/src/xercesc/framework/XMLEntityDecl.cpp index 4444a6c87436fc1609967e375800a02a03652dc4..10f0e9ae08b76f82786720f8c97632d508e3910a 100644 --- a/src/xercesc/framework/XMLEntityDecl.cpp +++ b/src/xercesc/framework/XMLEntityDecl.cpp @@ -64,7 +64,7 @@ // --------------------------------------------------------------------------- #include <xercesc/framework/XMLEntityDecl.hpp> #include <xercesc/util/XMLUniDefs.hpp> - +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -119,6 +119,10 @@ XMLEntityDecl::XMLEntityDecl(const XMLCh* const entName fValue = XMLString::replicate(value, fMemoryManager); fName = XMLString::replicate(entName, fMemoryManager); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); @@ -145,6 +149,10 @@ XMLEntityDecl::XMLEntityDecl(const XMLCh* const entName fValue = XMLString::replicate(dummy, fMemoryManager); fName = XMLString::replicate(entName, fMemoryManager); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); diff --git a/src/xercesc/framework/XMLNotationDecl.cpp b/src/xercesc/framework/XMLNotationDecl.cpp index 4c451b83605fcff351bf2d4036f54538d521aa2f..7a9c4a0e240ef054bf1499266f682a2c7a63076a 100644 --- a/src/xercesc/framework/XMLNotationDecl.cpp +++ b/src/xercesc/framework/XMLNotationDecl.cpp @@ -56,6 +56,9 @@ /** * $Log$ + * Revision 1.7 2003/10/01 16:32:38 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.6 2003/05/16 21:36:55 knoaman * Memory manager implementation: Modify constructors to pass in the memory manager. * @@ -90,6 +93,7 @@ // Includes // --------------------------------------------------------------------------- #include <xercesc/framework/XMLNotationDecl.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -126,6 +130,10 @@ XMLNotationDecl::XMLNotationDecl( const XMLCh* const notName fSystemId = XMLString::replicate(sysId, fMemoryManager); fBaseURI = XMLString::replicate(baseURI, fMemoryManager); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); diff --git a/src/xercesc/internal/DGXMLScanner.cpp b/src/xercesc/internal/DGXMLScanner.cpp index 6d3933a2832e4d91afc5d68e3b1f37f23bdff1cc..a2384650a7b272c56d84143fe9f3ce9fbc7c1160 100644 --- a/src/xercesc/internal/DGXMLScanner.cpp +++ b/src/xercesc/internal/DGXMLScanner.cpp @@ -78,6 +78,7 @@ #include <xercesc/validators/DTD/DocTypeHandler.hpp> #include <xercesc/validators/DTD/DTDScanner.hpp> #include <xercesc/validators/DTD/DTDValidator.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -109,6 +110,10 @@ DGXMLScanner::DGXMLScanner(XMLValidator* const valToAdopt fValidator = fDTDValidator; } } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); @@ -145,6 +150,10 @@ DGXMLScanner::DGXMLScanner( XMLDocumentHandler* const docHandler fValidator = fDTDValidator; } } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); @@ -273,6 +282,10 @@ void DGXMLScanner::scanDocument(const InputSource& src) , excToCatch.getMessage() ); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Flush the reader manager and rethrow user's error @@ -283,6 +296,10 @@ void DGXMLScanner::scanDocument(const InputSource& src) // If it returned, then reset the reader manager and fall through fReaderMgr.reset(); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Reset and rethrow @@ -447,6 +464,10 @@ bool DGXMLScanner::scanNext(XMLPScanToken& token) , excToCatch.getMessage() ); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Reset and rethrow user error @@ -458,6 +479,10 @@ bool DGXMLScanner::scanNext(XMLPScanToken& token) fReaderMgr.reset(); return false; } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Reset and rethrow original error @@ -1685,7 +1710,10 @@ Grammar* DGXMLScanner::loadGrammar(const InputSource& src , excToCatch.getMessage() ); } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Flush the reader manager and rethrow user's error @@ -1696,6 +1724,10 @@ Grammar* DGXMLScanner::loadGrammar(const InputSource& src // If it returned, then reset the reader manager and fall through fReaderMgr.reset(); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Reset and rethrow diff --git a/src/xercesc/internal/IGXMLScanner.cpp b/src/xercesc/internal/IGXMLScanner.cpp index e18c88cdf5ae1be74e9439a7036e89db079e0279..84cd9d8689c6539bce32cdf6e7ab022b4e9c9204 100644 --- a/src/xercesc/internal/IGXMLScanner.cpp +++ b/src/xercesc/internal/IGXMLScanner.cpp @@ -83,6 +83,7 @@ #include <xercesc/validators/schema/identity/ValueStoreCache.hpp> #include <xercesc/validators/schema/identity/IC_Selector.hpp> #include <xercesc/validators/schema/identity/ValueStore.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -117,6 +118,10 @@ IGXMLScanner::IGXMLScanner( XMLValidator* const valToAdopt if (!valToAdopt) fValidator = fDTDValidator; } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); @@ -156,6 +161,10 @@ IGXMLScanner::IGXMLScanner( XMLDocumentHandler* const docHandler if (!valToAdopt) fValidator = fDTDValidator; } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); @@ -284,6 +293,10 @@ void IGXMLScanner::scanDocument(const InputSource& src) , excToCatch.getMessage() ); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Flush the reader manager and rethrow user's error @@ -294,6 +307,10 @@ void IGXMLScanner::scanDocument(const InputSource& src) // If it returned, then reset the reader manager and fall through fReaderMgr.reset(); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Reset and rethrow @@ -464,6 +481,10 @@ bool IGXMLScanner::scanNext(XMLPScanToken& token) , excToCatch.getMessage() ); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Reset and rethrow user error @@ -475,6 +496,10 @@ bool IGXMLScanner::scanNext(XMLPScanToken& token) fReaderMgr.reset(); return false; } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Reset and rethrow original error @@ -2934,7 +2959,10 @@ Grammar* IGXMLScanner::loadGrammar(const InputSource& src , excToCatch.getMessage() ); } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Flush the reader manager and rethrow user's error @@ -2945,6 +2973,10 @@ Grammar* IGXMLScanner::loadGrammar(const InputSource& src // If it returned, then reset the reader manager and fall through fReaderMgr.reset(); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Reset and rethrow diff --git a/src/xercesc/internal/MemoryManagerArrayImpl.cpp b/src/xercesc/internal/MemoryManagerArrayImpl.cpp index 823e6026d1e34f7deb978c7470bd86be616535dd..f17a5e877e13cb087fefc98c1749d84cd9346f24 100644 --- a/src/xercesc/internal/MemoryManagerArrayImpl.cpp +++ b/src/xercesc/internal/MemoryManagerArrayImpl.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.3 2003/10/01 16:32:38 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.2 2003/09/06 22:37:55 jberry * Fix bug #22938. Deletion of void* is illegal. Thanks Dave Bertoni. * @@ -69,14 +72,26 @@ // Includes // --------------------------------------------------------------------------- #include <xercesc/internal/MemoryManagerArrayImpl.hpp> - +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN void* MemoryManagerArrayImpl::allocate(size_t size) { - //return ::operator new[](size); - return new char[size]; + + void* memptr; + try { + //return ::operator new[](size); + //return new char[size]; + memptr = new char[size]; + } + catch(...) { + throw OutOfMemoryException(); + } + if (memptr != NULL) { + return memptr; + } + throw OutOfMemoryException(); } void MemoryManagerArrayImpl::deallocate(void* p) @@ -87,3 +102,4 @@ void MemoryManagerArrayImpl::deallocate(void* p) XERCES_CPP_NAMESPACE_END + \ No newline at end of file diff --git a/src/xercesc/internal/MemoryManagerImpl.cpp b/src/xercesc/internal/MemoryManagerImpl.cpp index 428259dd4ecd4d7a0fde3ca49e92e6fabc5dae90..5955d9d3a58f9a730e7e99fd706261c47df4ff33 100644 --- a/src/xercesc/internal/MemoryManagerImpl.cpp +++ b/src/xercesc/internal/MemoryManagerImpl.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.2 2003/10/01 16:32:38 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.1 2003/04/21 16:20:41 knoaman * Initial check-in. * @@ -66,13 +69,23 @@ // Includes // --------------------------------------------------------------------------- #include <xercesc/internal/MemoryManagerImpl.hpp> - +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN void* MemoryManagerImpl::allocate(size_t size) { - return ::operator new(size); + void* memptr; + try { + memptr = ::operator new(size); + } + catch(...) { + throw OutOfMemoryException(); + } + if (memptr != NULL) { + return memptr; + } + throw OutOfMemoryException(); } void MemoryManagerImpl::deallocate(void* p) @@ -81,4 +94,4 @@ void MemoryManagerImpl::deallocate(void* p) } XERCES_CPP_NAMESPACE_END - + \ No newline at end of file diff --git a/src/xercesc/internal/ReaderMgr.cpp b/src/xercesc/internal/ReaderMgr.cpp index 727d86b4fbbeb80925c4e620a8ca4fbe061904c9..21fa255da9c9629b4bc66f77a94ca46d6f513df7 100644 --- a/src/xercesc/internal/ReaderMgr.cpp +++ b/src/xercesc/internal/ReaderMgr.cpp @@ -78,6 +78,7 @@ #include <xercesc/framework/XMLEntityHandler.hpp> #include <xercesc/internal/EndOfEntityException.hpp> #include <xercesc/internal/ReaderMgr.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -474,7 +475,10 @@ XMLReader* ReaderMgr::createReader( const InputSource& src ); } } - + catch(const OutOfMemoryException&) + { + throw; + } catch (...) //NetAccessorException& { delete newStream; diff --git a/src/xercesc/internal/SGXMLScanner.cpp b/src/xercesc/internal/SGXMLScanner.cpp index 37d458aae9396147f6d0485735c3ec01412a83a2..61dee6478ac60c4eb2e1652997957c571b956c32 100644 --- a/src/xercesc/internal/SGXMLScanner.cpp +++ b/src/xercesc/internal/SGXMLScanner.cpp @@ -84,6 +84,7 @@ #include <xercesc/validators/schema/identity/ValueStoreCache.hpp> #include <xercesc/validators/schema/identity/IC_Selector.hpp> #include <xercesc/validators/schema/identity/ValueStore.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -122,6 +123,10 @@ SGXMLScanner::SGXMLScanner( XMLValidator* const valToAdopt fValidator = fSchemaValidator; } } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); @@ -165,6 +170,10 @@ SGXMLScanner::SGXMLScanner( XMLDocumentHandler* const docHandler fValidator = fSchemaValidator; } } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); @@ -293,6 +302,10 @@ void SGXMLScanner::scanDocument(const InputSource& src) , excToCatch.getMessage() ); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Flush the reader manager and rethrow user's error @@ -303,6 +316,10 @@ void SGXMLScanner::scanDocument(const InputSource& src) // If it returned, then reset the reader manager and fall through fReaderMgr.reset(); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Reset and rethrow @@ -470,6 +487,10 @@ bool SGXMLScanner::scanNext(XMLPScanToken& token) , excToCatch.getMessage() ); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Reset and rethrow user error @@ -481,6 +502,10 @@ bool SGXMLScanner::scanNext(XMLPScanToken& token) fReaderMgr.reset(); return false; } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Reset and rethrow original error @@ -1870,7 +1895,10 @@ Grammar* SGXMLScanner::loadGrammar(const InputSource& src , excToCatch.getMessage() ); } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Flush the reader manager and rethrow user's error @@ -1881,6 +1909,10 @@ Grammar* SGXMLScanner::loadGrammar(const InputSource& src // If it returned, then reset the reader manager and fall through fReaderMgr.reset(); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Reset and rethrow diff --git a/src/xercesc/internal/WFXMLScanner.cpp b/src/xercesc/internal/WFXMLScanner.cpp index 50bd6df80696a71f404c3767cdd77862c2d0d541..8707960d626fc2dd3e55b24d6e1d6aa0009bbc03 100644 --- a/src/xercesc/internal/WFXMLScanner.cpp +++ b/src/xercesc/internal/WFXMLScanner.cpp @@ -72,7 +72,7 @@ #include <xercesc/framework/XMLPScanToken.hpp> #include <xercesc/framework/XMLValidityCodes.hpp> #include <xercesc/internal/EndOfEntityException.hpp> - +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -96,6 +96,10 @@ WFXMLScanner::WFXMLScanner( XMLValidator* const valToAdopt { commonInit(); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); @@ -124,6 +128,10 @@ WFXMLScanner::WFXMLScanner( XMLDocumentHandler* const docHandler { commonInit(); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); @@ -241,6 +249,10 @@ void WFXMLScanner::scanDocument(const InputSource& src) , excToCatch.getMessage() ); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Flush the reader manager and rethrow user's error @@ -251,6 +263,10 @@ void WFXMLScanner::scanDocument(const InputSource& src) // If it returned, then reset the reader manager and fall through fReaderMgr.reset(); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Reset and rethrow @@ -406,6 +422,10 @@ bool WFXMLScanner::scanNext(XMLPScanToken& token) , excToCatch.getMessage() ); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Reset and rethrow user error @@ -417,6 +437,10 @@ bool WFXMLScanner::scanNext(XMLPScanToken& token) fReaderMgr.reset(); return false; } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Reset and rethrow original error diff --git a/src/xercesc/internal/XMLScanner.cpp b/src/xercesc/internal/XMLScanner.cpp index 45b2fb4e9f9a8ff6206ab7d664170f15d65a7e11..6ea693699b09163b89435988bc24f13973a764c0 100644 --- a/src/xercesc/internal/XMLScanner.cpp +++ b/src/xercesc/internal/XMLScanner.cpp @@ -78,6 +78,7 @@ #include <xercesc/internal/EndOfEntityException.hpp> #include <xercesc/validators/DTD/DocTypeHandler.hpp> #include <xercesc/validators/common/GrammarResolver.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -416,6 +417,10 @@ void XMLScanner::scanDocument( const XMLCh* const systemId) ); return; } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Just rethrow this, since its not our problem @@ -531,6 +536,10 @@ bool XMLScanner::scanFirst( const XMLCh* const systemId ); return false; } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Just rethrow this, since its not our problem @@ -626,6 +635,10 @@ bool XMLScanner::scanFirst( const InputSource& src , excToCatch.getMessage() ); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Reset and rethrow the user error @@ -637,6 +650,10 @@ bool XMLScanner::scanFirst( const InputSource& src fReaderMgr.reset(); return false; } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Reset and rethrow original error @@ -1659,6 +1676,10 @@ Grammar* XMLScanner::loadGrammar(const XMLCh* const systemId ); return 0; } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Just rethrow this, since its not our problem diff --git a/src/xercesc/parsers/AbstractDOMParser.cpp b/src/xercesc/parsers/AbstractDOMParser.cpp index b4dbe0131c82c07955c19747162449955f1f6d71..151dde79454ea6c3ced22993189b38fbbe4e7aee 100644 --- a/src/xercesc/parsers/AbstractDOMParser.cpp +++ b/src/xercesc/parsers/AbstractDOMParser.cpp @@ -71,7 +71,7 @@ #include <xercesc/parsers/AbstractDOMParser.hpp> #include <xercesc/internal/XMLScannerResolver.hpp> #include <xercesc/internal/ElemStack.hpp> -#include <xercesc/sax/EntityResolver.hpp> +//#include <xercesc/sax/EntityResolver.hpp> #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/framework/XMLNotationDecl.hpp> #include <xercesc/framework/XMLValidator.hpp> @@ -97,6 +97,8 @@ #include <xercesc/validators/common/ContentSpecNode.hpp> #include <xercesc/validators/common/GrammarResolver.hpp> #include <xercesc/validators/schema/SchemaSymbols.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> + XERCES_CPP_NAMESPACE_BEGIN @@ -134,6 +136,10 @@ AbstractDOMParser::AbstractDOMParser( XMLValidator* const valToAdopt { initialize(); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); @@ -441,7 +447,10 @@ void AbstractDOMParser::parse(const InputSource& source) fScanner->scanDocument(source); fParseInProgress = false; } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { fParseInProgress = false; @@ -461,7 +470,10 @@ void AbstractDOMParser::parse(const XMLCh* const systemId) fScanner->scanDocument(systemId); fParseInProgress = false; } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { fParseInProgress = false; @@ -481,7 +493,10 @@ void AbstractDOMParser::parse(const char* const systemId) fScanner->scanDocument(systemId); fParseInProgress = false; } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { fParseInProgress = false; diff --git a/src/xercesc/parsers/DOMBuilderImpl.cpp b/src/xercesc/parsers/DOMBuilderImpl.cpp index 603027f791ac3c5948ac25cb143ce6c0e809099a..6b3f86596c677ab02004d5553bc877568fc92640 100644 --- a/src/xercesc/parsers/DOMBuilderImpl.cpp +++ b/src/xercesc/parsers/DOMBuilderImpl.cpp @@ -82,6 +82,7 @@ #include <xercesc/framework/XMLSchemaDescription.hpp> #include <xercesc/util/Janitor.hpp> #include <xercesc/validators/common/GrammarResolver.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -563,7 +564,10 @@ Grammar* DOMBuilderImpl::loadGrammar(const char* const systemId, getScanner()->setDocTypeHandler(this); setParseInProgress(false); } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { if (grammarType == Grammar::DTDGrammarType) @@ -600,7 +604,10 @@ Grammar* DOMBuilderImpl::loadGrammar(const XMLCh* const systemId, getScanner()->setDocTypeHandler(this); setParseInProgress(false); } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { if (grammarType == Grammar::DTDGrammarType) @@ -639,7 +646,10 @@ Grammar* DOMBuilderImpl::loadGrammar(const DOMInputSource& source, getScanner()->setDocTypeHandler(this); setParseInProgress(false); } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { if (grammarType == Grammar::DTDGrammarType) diff --git a/src/xercesc/parsers/SAX2XMLReaderImpl.cpp b/src/xercesc/parsers/SAX2XMLReaderImpl.cpp index 1480f6d842103f5a884324c6cb79df9651accbcd..373578737e3b323f3d296c68c0b626e4335458b8 100644 --- a/src/xercesc/parsers/SAX2XMLReaderImpl.cpp +++ b/src/xercesc/parsers/SAX2XMLReaderImpl.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.28 2003/10/01 16:32:38 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.27 2003/09/16 18:30:54 neilg * make Grammar pool be responsible for creating and owning URI string pools. This is one more step towards having grammars be independent of the parsers involved in their creation * @@ -302,7 +305,7 @@ #include <xercesc/validators/common/GrammarResolver.hpp> #include <xercesc/framework/XMLGrammarPool.hpp> #include <xercesc/framework/XMLSchemaDescription.hpp> - +#include <xercesc/util/OutOfMemoryException.hpp> #include <string.h> XERCES_CPP_NAMESPACE_BEGIN @@ -346,6 +349,10 @@ SAX2XMLReaderImpl::SAX2XMLReaderImpl(MemoryManager* const manager { initialize(); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); @@ -620,7 +627,10 @@ void SAX2XMLReaderImpl::parse (const InputSource& source) fScanner->scanDocument(source); fParseInProgress = false; } - + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { fParseInProgress = false; @@ -640,7 +650,10 @@ void SAX2XMLReaderImpl::parse (const XMLCh* const systemId) fScanner->scanDocument(systemId); fParseInProgress = false; } - + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { fParseInProgress = false; @@ -660,7 +673,10 @@ void SAX2XMLReaderImpl::parse (const char* const systemId) fScanner->scanDocument(systemId); fParseInProgress = false; } - + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { fParseInProgress = false; @@ -1659,7 +1675,10 @@ Grammar* SAX2XMLReaderImpl::loadGrammar(const char* const systemId, grammar = fScanner->loadGrammar(systemId, grammarType, toCache); fParseInProgress = false; } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { fParseInProgress = false; @@ -1684,7 +1703,10 @@ Grammar* SAX2XMLReaderImpl::loadGrammar(const XMLCh* const systemId, grammar = fScanner->loadGrammar(systemId, grammarType, toCache); fParseInProgress = false; } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { fParseInProgress = false; @@ -1709,7 +1731,10 @@ Grammar* SAX2XMLReaderImpl::loadGrammar(const InputSource& source, grammar = fScanner->loadGrammar(source, grammarType, toCache); fParseInProgress = false; } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { fParseInProgress = false; diff --git a/src/xercesc/parsers/SAXParser.cpp b/src/xercesc/parsers/SAXParser.cpp index 852fdf193c9c515cb5a2897c07668ed57656b636..ee617510d8a1d312b9f41c413c6625c43cea4f74 100644 --- a/src/xercesc/parsers/SAXParser.cpp +++ b/src/xercesc/parsers/SAXParser.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.26 2003/10/01 16:32:38 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.25 2003/09/16 18:30:54 neilg * make Grammar pool be responsible for creating and owning URI string pools. This is one more step towards having grammars be independent of the parsers involved in their creation * @@ -264,6 +267,7 @@ #include <xercesc/framework/XMLGrammarPool.hpp> #include <xercesc/framework/XMLSchemaDescription.hpp> #include <xercesc/util/Janitor.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> #include <string.h> XERCES_CPP_NAMESPACE_BEGIN @@ -297,6 +301,10 @@ SAXParser::SAXParser( XMLValidator* const valToAdopt { initialize(); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); @@ -682,7 +690,10 @@ void SAXParser::parse(const InputSource& source) fScanner->scanDocument(source); fParseInProgress = false; } - + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { fParseInProgress = false; @@ -702,7 +713,10 @@ void SAXParser::parse(const XMLCh* const systemId) fScanner->scanDocument(systemId); fParseInProgress = false; } - + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { fParseInProgress = false; @@ -722,7 +736,10 @@ void SAXParser::parse(const char* const systemId) fScanner->scanDocument(systemId); fParseInProgress = false; } - + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { fParseInProgress = false; @@ -1386,7 +1403,10 @@ Grammar* SAXParser::loadGrammar(const char* const systemId, grammar = fScanner->loadGrammar(systemId, grammarType, toCache); fParseInProgress = false; } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { fParseInProgress = false; @@ -1411,7 +1431,10 @@ Grammar* SAXParser::loadGrammar(const XMLCh* const systemId, grammar = fScanner->loadGrammar(systemId, grammarType, toCache); fParseInProgress = false; } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { fParseInProgress = false; @@ -1436,7 +1459,10 @@ Grammar* SAXParser::loadGrammar(const InputSource& source, grammar = fScanner->loadGrammar(source, grammarType, toCache); fParseInProgress = false; } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { fParseInProgress = false; diff --git a/src/xercesc/parsers/XercesDOMParser.cpp b/src/xercesc/parsers/XercesDOMParser.cpp index 7b8288f2ede9da549d4eca1030b2ae5261ae6595..71cb7affc6a8f2d68672db7f5a57f0c46e8e1455 100644 --- a/src/xercesc/parsers/XercesDOMParser.cpp +++ b/src/xercesc/parsers/XercesDOMParser.cpp @@ -78,6 +78,7 @@ #include <xercesc/framework/XMLGrammarPool.hpp> #include <xercesc/framework/XMLSchemaDescription.hpp> #include <xercesc/util/Janitor.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -272,7 +273,10 @@ Grammar* XercesDOMParser::loadGrammar(const char* const systemId, getScanner()->setDocTypeHandler(this); setParseInProgress(false); } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { if (grammarType == Grammar::DTDGrammarType) @@ -303,7 +307,10 @@ Grammar* XercesDOMParser::loadGrammar(const XMLCh* const systemId, getScanner()->setDocTypeHandler(this); setParseInProgress(false); } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { if (grammarType == Grammar::DTDGrammarType) @@ -334,7 +341,10 @@ Grammar* XercesDOMParser::loadGrammar(const InputSource& source, getScanner()->setDocTypeHandler(this); setParseInProgress(false); } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { if (grammarType == Grammar::DTDGrammarType) diff --git a/src/xercesc/util/Makefile.in b/src/xercesc/util/Makefile.in index 6c0ac6f793f56b797d6023cf4957eb310056fc03..e6a223932db717bcf100b5ef0056919318aca8f2 100644 --- a/src/xercesc/util/Makefile.in +++ b/src/xercesc/util/Makefile.in @@ -55,6 +55,9 @@ # # # $Log$ +# Revision 1.37 2003/10/01 16:32:39 neilg +# improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. +# # Revision 1.36 2003/05/29 11:27:51 gareth # fix to bug #20325. Removed unused file and updated Projects. # @@ -498,6 +501,7 @@ UTIL_CPP_PUBHEADERS = \ NoSuchElementException.hpp \ NullPointerException.hpp \ NumberFormatException.hpp \ + OutOfMemoryException.hpp \ PanicHandler.hpp \ ParseException.hpp \ PlatformUtils.hpp \ diff --git a/src/xercesc/util/OutOfMemoryException.hpp b/src/xercesc/util/OutOfMemoryException.hpp new file mode 100755 index 0000000000000000000000000000000000000000..ac84439beab570b312ee7457333c6a37611a3acd --- /dev/null +++ b/src/xercesc/util/OutOfMemoryException.hpp @@ -0,0 +1,134 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2000 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 1999, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + */ + +#if !defined(OUT_OF_MEMORY_EXCEPTION_HPP) +#define OUT_OF_MEMORY_EXCEPTION_HPP + +#include <xercesc/util/XMemory.hpp> +#include <xercesc/util/XMLExceptMsgs.hpp> +#include <xercesc/util/XMLUniDefs.hpp> + +XERCES_CPP_NAMESPACE_BEGIN + +const XMLCh gDefOutOfMemoryErrMsg[] = +{ + chLatin_O, chLatin_u, chLatin_t, chLatin_O + , chLatin_f, chLatin_M, chLatin_e, chLatin_m + , chLatin_o, chLatin_r, chLatin_y, chNull +}; + +class XMLUTIL_EXPORT OutOfMemoryException : public XMemory +{ +public: + + OutOfMemoryException(); + ~OutOfMemoryException(); + // ----------------------------------------------------------------------- + // Getter methods + // ----------------------------------------------------------------------- + XMLExcepts::Codes getCode() const; + const XMLCh* getMessage() const; + const XMLCh* getType() const; + const char* getSrcFile() const; + unsigned int getSrcLine() const; + + OutOfMemoryException(const OutOfMemoryException& toCopy); + OutOfMemoryException& operator=(const OutOfMemoryException& toAssign); +}; + +// constructors/destructors... +inline OutOfMemoryException::OutOfMemoryException() {} +inline OutOfMemoryException::~OutOfMemoryException() {} +inline OutOfMemoryException::OutOfMemoryException(const OutOfMemoryException& toCopy) {} +inline OutOfMemoryException& OutOfMemoryException::operator=(const OutOfMemoryException& toAssign) +{ + return *this; +} + +// --------------------------------------------------------------------------- +// OutOfMemoryException: Getter methods +// --------------------------------------------------------------------------- +inline XMLExcepts::Codes OutOfMemoryException::getCode() const +{ + return XMLExcepts::Out_Of_Memory; +} + +inline const XMLCh* OutOfMemoryException::getMessage() const +{ + return gDefOutOfMemoryErrMsg; +} + +inline const XMLCh* OutOfMemoryException::getType() const +{ + return gDefOutOfMemoryErrMsg; +} + +inline const char* OutOfMemoryException::getSrcFile() const +{ + return ""; +} + +inline unsigned int OutOfMemoryException::getSrcLine() const { + return 0; +} + +XERCES_CPP_NAMESPACE_END + +#endif diff --git a/src/xercesc/util/Platforms/AIX/AIXPlatformUtils.cpp b/src/xercesc/util/Platforms/AIX/AIXPlatformUtils.cpp index 6ef3695dc88566dc248fb3274979a18badfd0f0c..6782c3ee457a75381890bf2e92dab1554675c307 100644 --- a/src/xercesc/util/Platforms/AIX/AIXPlatformUtils.cpp +++ b/src/xercesc/util/Platforms/AIX/AIXPlatformUtils.cpp @@ -87,6 +87,7 @@ #include <xercesc/util/XMLString.hpp> #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/PanicHandler.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> #if defined (XML_USE_ICU_TRANSCODER) #include <xercesc/util/Transcoders/ICU/ICUTransService.hpp> @@ -161,7 +162,10 @@ XMLMsgLoader* XMLPlatformUtils::loadAMsgSet(const XMLCh* const msgDomain) retVal = new InMemMsgLoader(msgDomain); #endif } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { panic(PanicHandler::Panic_CantLoadMsgDomain); diff --git a/src/xercesc/util/Platforms/BeOS/BeOSPlatformUtils.cpp b/src/xercesc/util/Platforms/BeOS/BeOSPlatformUtils.cpp index 28c9d9d0f6f538149f710484e86ec2117ef98f88..0253cb9db729fc1d8aa0b17bbdb9b2afd1dc5bcd 100644 --- a/src/xercesc/util/Platforms/BeOS/BeOSPlatformUtils.cpp +++ b/src/xercesc/util/Platforms/BeOS/BeOSPlatformUtils.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.8 2003/10/01 16:32:39 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.7 2003/05/15 18:37:47 knoaman * Partial implementation of the configurable memory manager. * @@ -115,6 +118,7 @@ #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/XMLUni.hpp> #include <xercesc/util/PanicHandler.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> #include <Path.h> char *realpath(const char *path, char *resolved_path) { @@ -183,7 +187,10 @@ XMLMsgLoader* XMLPlatformUtils::loadAMsgSet(const XMLCh* const msgDomain) retVal = new InMemMsgLoader(msgDomain); #endif } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { panic(PanicHandler::Panic_CantLoadMsgDomain); diff --git a/src/xercesc/util/Platforms/FreeBSD/FreeBSDPlatformUtils.cpp b/src/xercesc/util/Platforms/FreeBSD/FreeBSDPlatformUtils.cpp index b52130329186696b8cb6996660cb519ab6228a1a..4ac1334a900af30b2f6a5d08ac4275de44e41e67 100644 --- a/src/xercesc/util/Platforms/FreeBSD/FreeBSDPlatformUtils.cpp +++ b/src/xercesc/util/Platforms/FreeBSD/FreeBSDPlatformUtils.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.14 2003/10/01 16:32:39 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.13 2003/05/15 18:37:47 knoaman * Partial implementation of the configurable memory manager. * @@ -136,6 +139,7 @@ #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/XMLUni.hpp> #include <xercesc/util/PanicHandler.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> #if defined(XML_USE_ICU_TRANSCODER) #include <xercesc/util/Transcoders/ICU/ICUTransService.hpp> @@ -195,7 +199,10 @@ XMLMsgLoader* XMLPlatformUtils::loadAMsgSet(const XMLCh* const msgDomain) retVal = new InMemMsgLoader(msgDomain); #endif } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { panic(PanicHandler::Panic_CantLoadMsgDomain); diff --git a/src/xercesc/util/Platforms/HPUX/HPPlatformUtils.cpp b/src/xercesc/util/Platforms/HPUX/HPPlatformUtils.cpp index b194234de9d40369ac0a8750468221ee3126ac66..5abe874983b51ab37dabe1c012436836d9a10ce8 100644 --- a/src/xercesc/util/Platforms/HPUX/HPPlatformUtils.cpp +++ b/src/xercesc/util/Platforms/HPUX/HPPlatformUtils.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.14 2003/10/01 16:32:39 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.13 2003/05/15 18:37:48 knoaman * Partial implementation of the configurable memory manager. * @@ -190,6 +193,7 @@ #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/XMLUni.hpp> #include <xercesc/util/PanicHandler.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> #if defined(XML_USE_ICU_TRANSCODER) #include <xercesc/util/Transcoders/ICU/ICUTransService.hpp> @@ -263,6 +267,10 @@ XMLMsgLoader* XMLPlatformUtils::loadAMsgSet(const XMLCh* const msgDomain) retVal = new InMemMsgLoader(msgDomain); #endif } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { panic(PanicHandler::Panic_CantLoadMsgDomain); diff --git a/src/xercesc/util/Platforms/IRIX/IRIXPlatformUtils.cpp b/src/xercesc/util/Platforms/IRIX/IRIXPlatformUtils.cpp index a505b73c021e01766664837f471337e5e54ff70d..ac1dae4120472f3dba7fffc31da2dbb9f7aa01a6 100644 --- a/src/xercesc/util/Platforms/IRIX/IRIXPlatformUtils.cpp +++ b/src/xercesc/util/Platforms/IRIX/IRIXPlatformUtils.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.13 2003/10/01 16:32:39 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.12 2003/05/15 18:37:48 knoaman * Partial implementation of the configurable memory manager. * @@ -173,6 +176,7 @@ #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/XMLUni.hpp> #include <xercesc/util/PanicHandler.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> #if defined(XML_USE_ICU_TRANSCODER) #include <xercesc/util/Transcoders/ICU/ICUTransService.hpp> @@ -230,7 +234,10 @@ XMLMsgLoader* XMLPlatformUtils::loadAMsgSet(const XMLCh* const msgDomain) retVal = new InMemMsgLoader(msgDomain); #endif } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { panic(PanicHandler::Panic_CantLoadMsgDomain); diff --git a/src/xercesc/util/Platforms/Linux/LinuxPlatformUtils.cpp b/src/xercesc/util/Platforms/Linux/LinuxPlatformUtils.cpp index 1c35de2d659f491c6753da40a270c6c6e1e0b2f4..a8add51d12fef45ec2aec05c855ca761e09f63c8 100644 --- a/src/xercesc/util/Platforms/Linux/LinuxPlatformUtils.cpp +++ b/src/xercesc/util/Platforms/Linux/LinuxPlatformUtils.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.17 2003/10/01 16:32:39 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.16 2003/05/15 18:37:48 knoaman * Partial implementation of the configurable memory manager. * @@ -217,6 +220,7 @@ #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/XMLUni.hpp> #include <xercesc/util/PanicHandler.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> #if defined(XML_USE_ICU_TRANSCODER) #include <xercesc/util/Transcoders/ICU/ICUTransService.hpp> @@ -279,7 +283,10 @@ XMLMsgLoader* XMLPlatformUtils::loadAMsgSet(const XMLCh* const msgDomain) retVal = new InMemMsgLoader(msgDomain); #endif } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { panic(PanicHandler::Panic_CantLoadMsgDomain); diff --git a/src/xercesc/util/Platforms/NetBSD/NetBSDPlatformUtils.cpp b/src/xercesc/util/Platforms/NetBSD/NetBSDPlatformUtils.cpp index 6d98705b4d9d94390d2911129d9ace974e244412..fd21c75bd321b061472a009d083daaaf6f4319d8 100644 --- a/src/xercesc/util/Platforms/NetBSD/NetBSDPlatformUtils.cpp +++ b/src/xercesc/util/Platforms/NetBSD/NetBSDPlatformUtils.cpp @@ -89,6 +89,7 @@ #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/XMLUni.hpp> #include <xercesc/util/PanicHandler.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> #if defined(XML_USE_ICU_TRANSCODER) #include <xercesc/util/Transcoders/ICU/ICUTransService.hpp> @@ -177,7 +178,10 @@ XMLMsgLoader* XMLPlatformUtils::loadAMsgSet(const XMLCh* const msgDomain) retVal = new InMemMsgLoader(msgDomain); #endif } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { panic(PanicHandler::Panic_CantLoadMsgDomain); diff --git a/src/xercesc/util/Platforms/OS390/OS390PlatformUtils.cpp b/src/xercesc/util/Platforms/OS390/OS390PlatformUtils.cpp index d557ff2c8219566b10c019617e73fc51e3df486b..8b084a4abd9ba32c97d8081044f19b0f6080d7c3 100644 --- a/src/xercesc/util/Platforms/OS390/OS390PlatformUtils.cpp +++ b/src/xercesc/util/Platforms/OS390/OS390PlatformUtils.cpp @@ -91,6 +91,7 @@ #include <xercesc/util/PanicHandler.hpp> #include "Path390.hpp" #include "FileHandleImpl.hpp" +#include <xercesc/util/OutOfMemoryException.hpp> #if defined (XML_USE_ICU_TRANSCODER) #include <xercesc/util/Transcoders/ICU/ICUTransService.hpp> @@ -135,6 +136,10 @@ void XMLPlatformUtils::platformInit() { XMLPlatformUtils::recognizeNEL(true); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { panic(PanicHandler::Panic_SystemInit); @@ -157,6 +162,10 @@ void XMLPlatformUtils::platformInit() isPosixEnabled = true; } } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { panic(PanicHandler::Panic_SystemInit); @@ -195,10 +204,13 @@ XMLMsgLoader* XMLPlatformUtils::loadAMsgSet(const XMLCh* const msgDomain) retVal = new InMemMsgLoader(msgDomain); #endif } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { - panic(PanicHandler::Panic_CantLoadMsgDomain); + panic(PanicHandler::Panic_CantLoadMsgDomain); } return retVal; } diff --git a/src/xercesc/util/Platforms/OS400/OS400PlatformUtils.cpp b/src/xercesc/util/Platforms/OS400/OS400PlatformUtils.cpp index 7d140a435f9ac5232a47d8e69ccd788e1e8af1d5..481f5de2fb5822839e13400c01df2810bcba5378 100644 --- a/src/xercesc/util/Platforms/OS400/OS400PlatformUtils.cpp +++ b/src/xercesc/util/Platforms/OS400/OS400PlatformUtils.cpp @@ -80,6 +80,7 @@ #include <qmhsndpm.h> #include <except.h> #include <mih/cmpswp.h> +#include <xercesc/util/OutOfMemoryException.hpp> #if defined (XML_USE_ICONV400_TRANSCODER) #include <xercesc/util/Transcoders/Iconv400/Iconv400TransService.hpp> @@ -165,7 +166,10 @@ XMLMsgLoader* XMLPlatformUtils::loadAMsgSet(const XMLCh* const msgDomain) retVal = new InMemMsgLoader(msgDomain); #endif } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { panic( PanicHandler::Panic_CantLoadMsgDomain ); diff --git a/src/xercesc/util/Platforms/OpenServer/OpenServerPlatformUtils.cpp b/src/xercesc/util/Platforms/OpenServer/OpenServerPlatformUtils.cpp index 2b9fd57474ef25ad7986a1fe407edf045a046194..a842117820ef0f08207945a0ea8727607b38fcdd 100644 --- a/src/xercesc/util/Platforms/OpenServer/OpenServerPlatformUtils.cpp +++ b/src/xercesc/util/Platforms/OpenServer/OpenServerPlatformUtils.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.9 2003/10/01 16:32:40 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.8 2003/05/15 18:37:49 knoaman * Partial implementation of the configurable memory manager. * @@ -108,6 +111,7 @@ #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/XMLUni.hpp> #include <xercesc/util/PanicHandler.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> #if defined (XML_USE_ICU_TRANSCODER) # include <xercesc/util/Transcoders/ICU/ICUTransService.hpp> @@ -157,6 +161,10 @@ XMLMsgLoader* XMLPlatformUtils::loadAMsgSet(const XMLCh* const msgDomain) retVal = new InMemMsgLoader(msgDomain); #endif } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { panic(PanicHandler::Panic_CantLoadMsgDomain); diff --git a/src/xercesc/util/Platforms/Solaris/SolarisPlatformUtils.cpp b/src/xercesc/util/Platforms/Solaris/SolarisPlatformUtils.cpp index a952ac75c799c7ed5fb0401dd8acfbea6870e3fd..eda9307cde44b5d58bec0f629baf88985760538c 100644 --- a/src/xercesc/util/Platforms/Solaris/SolarisPlatformUtils.cpp +++ b/src/xercesc/util/Platforms/Solaris/SolarisPlatformUtils.cpp @@ -90,6 +90,7 @@ #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/XMLUni.hpp> #include <xercesc/util/PanicHandler.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> #if defined (XML_USE_ICU_TRANSCODER) #include <xercesc/util/Transcoders/ICU/ICUTransService.hpp> @@ -150,6 +151,10 @@ XMLMsgLoader* XMLPlatformUtils::loadAMsgSet(const XMLCh* const msgDomain) retVal = new InMemMsgLoader(msgDomain); #endif } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { panic(PanicHandler::Panic_CantLoadMsgDomain); diff --git a/src/xercesc/util/Platforms/Tandem/TandemPlatformUtils.cpp b/src/xercesc/util/Platforms/Tandem/TandemPlatformUtils.cpp index 5a84182e5caa1b8e324e2a8240f4895919e678c3..daf29b2f20f0514f72e40bcf51bf0f223ea09bd1 100644 --- a/src/xercesc/util/Platforms/Tandem/TandemPlatformUtils.cpp +++ b/src/xercesc/util/Platforms/Tandem/TandemPlatformUtils.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.10 2003/10/01 16:32:40 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.9 2003/05/15 18:37:49 knoaman * Partial implementation of the configurable memory manager. * @@ -119,6 +122,7 @@ #include <libgen.h> #include <sys/timeb.h> #include <string.h> +#include <xercesc/util/OutOfMemoryException.hpp> #if defined (XML_USE_ICU_MESSAGELOADER) #include <xercesc/util/MsgLoaders/ICU/ICUMsgLoader.hpp> @@ -155,6 +159,10 @@ XMLMsgLoader* XMLPlatformUtils::loadAMsgSet(const XMLCh* const msgDomain) retVal = new InMemMsgLoader(msgDomain); #endif } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { panic(PanicHandler::Panic_CantLoadMsgDomain); diff --git a/src/xercesc/util/Platforms/Tru64/Tru64PlatformUtils.cpp b/src/xercesc/util/Platforms/Tru64/Tru64PlatformUtils.cpp index 6ba7c8f34b0a9307c0fffa96793266e5fd62780f..9e7dbdbfa1fcfd461667b2fa46ed7ed037d88e10 100644 --- a/src/xercesc/util/Platforms/Tru64/Tru64PlatformUtils.cpp +++ b/src/xercesc/util/Platforms/Tru64/Tru64PlatformUtils.cpp @@ -79,6 +79,7 @@ #include <xercesc/util/XMLUni.hpp> #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/PanicHandler.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> // // These control which transcoding service is used by the Tru64 version. @@ -152,6 +153,10 @@ XMLMsgLoader* XMLPlatformUtils::loadAMsgSet(const XMLCh* const msgDomain) retVal = new InMemMsgLoader(msgDomain); #endif } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { panic(PanicHandler::Panic_CantLoadMsgDomain); diff --git a/src/xercesc/util/Platforms/UnixWare/UnixWarePlatformUtils.cpp b/src/xercesc/util/Platforms/UnixWare/UnixWarePlatformUtils.cpp index 5f2dc925e400afa3fd9bab764dd697ddb4e341c5..760db0ca3198ed8a38c99ebf5bdfd33e6a9d7768 100644 --- a/src/xercesc/util/Platforms/UnixWare/UnixWarePlatformUtils.cpp +++ b/src/xercesc/util/Platforms/UnixWare/UnixWarePlatformUtils.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.11 2003/10/01 16:32:40 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.10 2003/05/15 18:37:49 knoaman * Partial implementation of the configurable memory manager. * @@ -149,6 +152,7 @@ #include <xercesc/util/XMLString.hpp> #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/XMLUni.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> #if defined (XML_USE_ICU_TRANSCODER) #include <xercesc/util/Transcoders/ICU/ICUTransService.hpp> @@ -213,6 +217,10 @@ XMLMsgLoader* XMLPlatformUtils::loadAMsgSet(const XMLCh* const msgDomain) retVal = new InMemMsgLoader(msgDomain); #endif } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { panic(PanicHandler::Panic_CantLoadMsgDomain); diff --git a/src/xercesc/util/QName.cpp b/src/xercesc/util/QName.cpp index 1f3f3f0c9b03b99e03e33c78a0b0112d7d79277a..542566a0f24eeba9ed712fee9c76e83b600ec1b5 100644 --- a/src/xercesc/util/QName.cpp +++ b/src/xercesc/util/QName.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.11 2003/10/01 16:32:39 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.10 2003/09/25 22:24:28 peiyongz * Using writeString/readString * @@ -116,6 +119,7 @@ */ #include <xercesc/util/QName.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -157,6 +161,10 @@ QName::QName( const XMLCh* const prefix // setName(prefix, localPart, uriId); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); @@ -184,6 +192,10 @@ QName::QName( const XMLCh* const rawName // setName(rawName, uriId); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); diff --git a/src/xercesc/util/XMLBigDecimal.cpp b/src/xercesc/util/XMLBigDecimal.cpp index d582626fc62c99c40b07541090a6dcf813238d0f..a3d0d1b44305eebea00a3b3709c22a1e35b5951e 100644 --- a/src/xercesc/util/XMLBigDecimal.cpp +++ b/src/xercesc/util/XMLBigDecimal.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.14 2003/10/01 16:32:39 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.13 2003/09/25 22:24:28 peiyongz * Using writeString/readString * @@ -128,7 +131,7 @@ #include <xercesc/util/TransService.hpp> #include <xercesc/util/NumberFormatException.hpp> #include <xercesc/util/XMLChar.hpp> - +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -172,6 +175,10 @@ XMLBigDecimal::XMLBigDecimal(const XMLCh* const strValue, fIntVal = fRawData + fRawDataLen + 1; parseBigDecimal(strValue, fRawDataLen); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); diff --git a/src/xercesc/util/XMLStringTokenizer.cpp b/src/xercesc/util/XMLStringTokenizer.cpp index cb1c5e36ff4db452c8e4f9acef49bb0c3a6e2116..b242ef4265aa5604609f03c2e104a5e56b8b958a 100644 --- a/src/xercesc/util/XMLStringTokenizer.cpp +++ b/src/xercesc/util/XMLStringTokenizer.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.6 2003/10/01 16:32:39 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.5 2003/05/18 14:02:05 knoaman * Memory manager implementation: pass per instance manager. * @@ -81,6 +84,7 @@ // --------------------------------------------------------------------------- #include <xercesc/util/XMLStringTokenizer.hpp> #include <xercesc/util/XMLUniDefs.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -111,6 +115,10 @@ XMLStringTokenizer::XMLStringTokenizer( const XMLCh* const srcStr fTokens = new (fMemoryManager) RefArrayVectorOf<XMLCh>(4, true, fMemoryManager); } } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); } @@ -133,6 +141,10 @@ XMLStringTokenizer::XMLStringTokenizer(const XMLCh* const srcStr, fTokens = new (fMemoryManager) RefArrayVectorOf<XMLCh>(4, true, fMemoryManager); } } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); } diff --git a/src/xercesc/util/XMLURL.cpp b/src/xercesc/util/XMLURL.cpp index 4739d25f83c23bf3ef80a8f1eed208d798897456..3af97b1345359d4764d2cbf571efe79a62057edc 100644 --- a/src/xercesc/util/XMLURL.cpp +++ b/src/xercesc/util/XMLURL.cpp @@ -73,6 +73,7 @@ #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/XMLUni.hpp> #include <xercesc/util/XMLUri.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -223,6 +224,10 @@ XMLURL::XMLURL(const XMLCh* const baseURL { setURL(baseURL, relativeURL); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanup(); @@ -252,6 +257,10 @@ XMLURL::XMLURL(const XMLCh* const baseURL { setURL(baseURL, tmpRel); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanup(); @@ -278,6 +287,10 @@ XMLURL::XMLURL(const XMLURL& baseURL { setURL(baseURL, relativeURL); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanup(); @@ -306,6 +319,10 @@ XMLURL::XMLURL(const XMLURL& baseURL { setURL(baseURL, tmpRel); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanup(); @@ -333,6 +350,10 @@ XMLURL::XMLURL(const XMLCh* const urlText, { setURL(urlText); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanup(); @@ -361,6 +382,10 @@ XMLURL::XMLURL(const char* const urlText, { setURL(tmpText); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanup(); @@ -392,6 +417,10 @@ XMLURL::XMLURL(const XMLURL& toCopy) : fUser = XMLString::replicate(toCopy.fUser, fMemoryManager); fURLText = XMLString::replicate(toCopy.fURLText, fMemoryManager); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanup(); @@ -1438,3 +1467,4 @@ bool XMLURL::parse(const XMLCh* const urlText, XMLURL& xmlURL) XERCES_CPP_NAMESPACE_END + \ No newline at end of file diff --git a/src/xercesc/util/XMLUri.cpp b/src/xercesc/util/XMLUri.cpp index e15ce27f57c21e0a8cfa6e0c436acba7f55bcf76..2e1ed8e24b8fbf0935abba07401c4eff97af3e5d 100644 --- a/src/xercesc/util/XMLUri.cpp +++ b/src/xercesc/util/XMLUri.cpp @@ -65,6 +65,7 @@ #include <xercesc/util/XMLURL.hpp> #include <xercesc/util/XMLUri.hpp> #include <xercesc/util/XMLChar.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -264,6 +265,10 @@ XMLUri::XMLUri(const XMLCh* const uriSpec, try { initialize((XMLUri *)0, uriSpec); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { cleanUp(); @@ -288,6 +293,10 @@ XMLUri::XMLUri(const XMLUri* const baseURI try { initialize(baseURI, uriSpec); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { cleanUp(); @@ -310,6 +319,10 @@ XMLUri::XMLUri(const XMLUri& toCopy) try { initialize(toCopy); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { cleanUp(); @@ -323,6 +336,10 @@ XMLUri& XMLUri::operator=(const XMLUri& toAssign) try { initialize(toAssign); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { cleanUp(); @@ -775,6 +792,10 @@ void XMLUri::initializeAuthority(const XMLCh* const uriSpec) { port = XMLString::parseInt(portStr); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { throw; @@ -1098,6 +1119,10 @@ void XMLUri::setUserInfo(const XMLCh* const newUserInfo) { isConformantUserInfo(newUserInfo); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { throw; diff --git a/src/xercesc/util/regx/BMPattern.cpp b/src/xercesc/util/regx/BMPattern.cpp index 0b230ec743be1138c052388976658a853720bb33..8352352ae6afaae81c2ca264daee8578416a6e8b 100644 --- a/src/xercesc/util/regx/BMPattern.cpp +++ b/src/xercesc/util/regx/BMPattern.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.4 2003/10/01 16:32:40 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.3 2003/05/15 18:42:54 knoaman * Partial implementation of the configurable memory manager. * @@ -80,6 +83,7 @@ #include <xercesc/util/XMLString.hpp> #include <xercesc/util/Janitor.hpp> #include <xercesc/framework/MemoryManager.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -101,7 +105,11 @@ BMPattern::BMPattern( const XMLCh* const pattern fPattern = XMLString::replicate(pattern, fMemoryManager); initialize(); } - catch(...) { + catch(const OutOfMemoryException&) + { + throw; + } + catch(...) { cleanUp(); throw; @@ -124,7 +132,11 @@ BMPattern::BMPattern( const XMLCh* const pattern fPattern = XMLString::replicate(pattern, fMemoryManager); initialize(); } - catch(...) { + catch(const OutOfMemoryException&) + { + throw; + } + catch(...) { cleanUp(); throw; diff --git a/src/xercesc/util/regx/RegularExpression.cpp b/src/xercesc/util/regx/RegularExpression.cpp index 655430f92316bb594b7372a98253d3ad39be6a6e..afaeb5167c5dcd5644f69b123cb07535b98ca62f 100644 --- a/src/xercesc/util/regx/RegularExpression.cpp +++ b/src/xercesc/util/regx/RegularExpression.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.15 2003/10/01 16:32:40 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.14 2003/08/14 02:57:27 knoaman * Code refactoring to improve performance of validation. * @@ -142,6 +145,7 @@ #include <xercesc/util/ParseException.hpp> #include <xercesc/util/IllegalArgumentException.hpp> #include <xercesc/framework/XMLBuffer.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -292,7 +296,11 @@ RegularExpression::RegularExpression(const char* const pattern, ArrayJanitor<XMLCh> janBuf(tmpBuf, fMemoryManager); setPattern(tmpBuf); } - catch (...) { + catch(const OutOfMemoryException&) + { + throw; + } + catch (...) { cleanUp(); throw; @@ -327,7 +335,11 @@ RegularExpression::RegularExpression(const char* const pattern, ArrayJanitor<XMLCh> janOps(tmpOptions, fMemoryManager); setPattern(tmpBuf, tmpOptions); } - catch (...) { + catch(const OutOfMemoryException&) + { + throw; + } + catch (...) { cleanUp(); throw; @@ -358,7 +370,11 @@ RegularExpression::RegularExpression(const XMLCh* const pattern, setPattern(pattern); } - catch (...) { + catch(const OutOfMemoryException&) + { + throw; + } + catch (...) { cleanUp(); throw; @@ -389,7 +405,11 @@ RegularExpression::RegularExpression(const XMLCh* const pattern, setPattern(pattern, options); } - catch (...) { + catch(const OutOfMemoryException&) + { + throw; + } + catch (...) { cleanUp(); throw; diff --git a/src/xercesc/validators/DTD/DTDScanner.cpp b/src/xercesc/validators/DTD/DTDScanner.cpp index 73a23a02770fdf3f18eb613d2ef1b142c7a6dcb9..53a1c612e84b734ee4e7a9df540a58202815553e 100644 --- a/src/xercesc/validators/DTD/DTDScanner.cpp +++ b/src/xercesc/validators/DTD/DTDScanner.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.29 2003/10/01 16:32:41 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.28 2003/07/10 19:50:12 peiyongz * Stateless Grammar: create grammar components with grammarPool's memory Manager * @@ -247,7 +250,7 @@ #include <xercesc/validators/DTD/DTDEntityDecl.hpp> #include <xercesc/validators/DTD/DocTypeHandler.hpp> #include <xercesc/validators/DTD/DTDScanner.hpp> - +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -518,7 +521,10 @@ bool DTDScanner::expandPERef( const bool scanExternal { scanExtSubsetDecl(false, false); } - + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { // Pop the reader back to the original level diff --git a/src/xercesc/validators/datatype/AnyURIDatatypeValidator.cpp b/src/xercesc/validators/datatype/AnyURIDatatypeValidator.cpp index 7f430fd875a7680ca78987e98abdaf4519ef234f..b7e57394b4a90a26d7392a224ff68a5fa744b495 100644 --- a/src/xercesc/validators/datatype/AnyURIDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/AnyURIDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.9 2003/10/01 16:32:41 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.8 2003/10/01 00:27:12 knoaman * Performance: call a static method to check the validity of URI instead of * creating/deleting local objects. @@ -123,6 +126,7 @@ #include <xercesc/validators/datatype/AnyURIDatatypeValidator.hpp> #include <xercesc/validators/datatype/InvalidDatatypeFacetException.hpp> #include <xercesc/validators/datatype/InvalidDatatypeValueException.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -165,6 +169,10 @@ AnyURIDatatypeValidator::AnyURIDatatypeValidator( { init(enums); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { cleanUp(); @@ -228,6 +236,10 @@ void AnyURIDatatypeValidator::checkValueSpace(const XMLCh* const content) , content); } } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { ThrowXML1(InvalidDatatypeValueException diff --git a/src/xercesc/validators/datatype/DateDatatypeValidator.cpp b/src/xercesc/validators/datatype/DateDatatypeValidator.cpp index 648e02a4a61145e63d9b8c9409a597f643655aa4..cb8ebeeacf7a32cbd7f18d6914ec4843e5bbca83 100644 --- a/src/xercesc/validators/datatype/DateDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/DateDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/10/01 16:32:41 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.6 2003/08/14 03:00:11 knoaman * Code refactoring to improve performance of validation. * @@ -90,6 +93,7 @@ // Includes // --------------------------------------------------------------------------- #include <xercesc/validators/datatype/DateDatatypeValidator.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -136,6 +140,10 @@ XMLDateTime* DateDatatypeValidator::parse(const XMLCh* const content) { pRetDate->parseDate(); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { delete pRetDate; diff --git a/src/xercesc/validators/datatype/DateTimeDatatypeValidator.cpp b/src/xercesc/validators/datatype/DateTimeDatatypeValidator.cpp index 348e959dd06fe24fae945f640e54bbf8d4f6e486..211f744157f99d4ed2694f8180d700795cfa32d8 100644 --- a/src/xercesc/validators/datatype/DateTimeDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/DateTimeDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/10/01 16:32:41 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.6 2003/08/14 03:00:11 knoaman * Code refactoring to improve performance of validation. * @@ -90,6 +93,7 @@ // Includes // --------------------------------------------------------------------------- #include <xercesc/validators/datatype/DateTimeDatatypeValidator.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -136,6 +140,10 @@ XMLDateTime* DateTimeDatatypeValidator::parse(const XMLCh* const content) { pRetDate->parseDateTime(); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { delete pRetDate; diff --git a/src/xercesc/validators/datatype/DateTimeValidator.cpp b/src/xercesc/validators/datatype/DateTimeValidator.cpp index e89688bf10e583943267ef059c885997eba204b0..6af6f7dde72edb2f41bae0feadc7681f006e6e91 100644 --- a/src/xercesc/validators/datatype/DateTimeValidator.cpp +++ b/src/xercesc/validators/datatype/DateTimeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.9 2003/10/01 16:32:41 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.8 2003/08/14 03:00:11 knoaman * Code refactoring to improve performance of validation. * @@ -97,6 +100,7 @@ #include <xercesc/validators/datatype/InvalidDatatypeFacetException.hpp> #include <xercesc/validators/datatype/InvalidDatatypeValueException.hpp> #include <xercesc/validators/schema/SchemaSymbols.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -151,6 +155,10 @@ int DateTimeValidator::compare(const XMLCh* const value1 int result = compareDates(pDate1, pDate2, true); return (result==INDETERMINATE)? -1 : result; } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) // RuntimeException e { return -1; // revisit after implement compareDates() diff --git a/src/xercesc/validators/datatype/DayDatatypeValidator.cpp b/src/xercesc/validators/datatype/DayDatatypeValidator.cpp index 5415b6d285b71729815739a5bb92320a5e06d553..1cade1ea4f33290bf90d1e1150d1e924de4b1d94 100644 --- a/src/xercesc/validators/datatype/DayDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/DayDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/10/01 16:32:41 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.6 2003/08/14 03:00:11 knoaman * Code refactoring to improve performance of validation. * @@ -90,6 +93,7 @@ // Includes // --------------------------------------------------------------------------- #include <xercesc/validators/datatype/DayDatatypeValidator.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -136,6 +140,10 @@ XMLDateTime* DayDatatypeValidator::parse(const XMLCh* const content) { pRetDate->parseDay(); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { delete pRetDate; diff --git a/src/xercesc/validators/datatype/DurationDatatypeValidator.cpp b/src/xercesc/validators/datatype/DurationDatatypeValidator.cpp index 4b1fb9cbee40af7aee54e5bed024bde1a54a3482..e9ce1c800db763f9d1a36405a7a62e8e587687c2 100644 --- a/src/xercesc/validators/datatype/DurationDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/DurationDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/10/01 16:32:41 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.6 2003/08/14 03:00:11 knoaman * Code refactoring to improve performance of validation. * @@ -90,6 +93,7 @@ // Includes // --------------------------------------------------------------------------- #include <xercesc/validators/datatype/DurationDatatypeValidator.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -136,6 +140,10 @@ XMLDateTime* DurationDatatypeValidator::parse(const XMLCh* const content) { pRetDate->parseDuration(); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { delete pRetDate; diff --git a/src/xercesc/validators/datatype/ListDatatypeValidator.cpp b/src/xercesc/validators/datatype/ListDatatypeValidator.cpp index 80e0f13355bf65e782ded12a4027b4546285427c..d4f73965bdacb9d11b0b69354db1209ccd95aabc 100644 --- a/src/xercesc/validators/datatype/ListDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/ListDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.11 2003/10/01 16:32:41 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.10 2003/09/30 21:31:30 peiyongz * Implementation of Serialization/Deserialization * @@ -122,6 +125,7 @@ #include <xercesc/validators/datatype/ListDatatypeValidator.hpp> #include <xercesc/validators/datatype/InvalidDatatypeFacetException.hpp> #include <xercesc/validators/datatype/InvalidDatatypeValueException.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -433,6 +437,10 @@ void ListDatatypeValidator::inspectFacetBase() for ( int j = 0; j < tokenNumber; j++) getBaseValidator()->validate(tempList->elementAt(j)); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { delete tempList; diff --git a/src/xercesc/validators/datatype/MonthDatatypeValidator.cpp b/src/xercesc/validators/datatype/MonthDatatypeValidator.cpp index 8d0b599e02fc3d020d5f18131744cd654f103003..8ae2dc150a49b9b543f65ad9e999293aa805baed 100644 --- a/src/xercesc/validators/datatype/MonthDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/MonthDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/10/01 16:32:41 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.6 2003/08/14 03:00:11 knoaman * Code refactoring to improve performance of validation. * @@ -90,6 +93,7 @@ // Includes // --------------------------------------------------------------------------- #include <xercesc/validators/datatype/MonthDatatypeValidator.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -136,6 +140,10 @@ XMLDateTime* MonthDatatypeValidator::parse(const XMLCh* const content) { pRetDate->parseMonth(); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { delete pRetDate; diff --git a/src/xercesc/validators/datatype/MonthDayDatatypeValidator.cpp b/src/xercesc/validators/datatype/MonthDayDatatypeValidator.cpp index de203c78b5fdac10f167b7a998c1620f5bc94865..6fe25dbcf079a66a3a54ae5591e4e2fdf4464fb0 100644 --- a/src/xercesc/validators/datatype/MonthDayDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/MonthDayDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/10/01 16:32:41 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.6 2003/08/14 03:00:11 knoaman * Code refactoring to improve performance of validation. * @@ -90,6 +93,7 @@ // Includes // --------------------------------------------------------------------------- #include <xercesc/validators/datatype/MonthDayDatatypeValidator.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -136,6 +140,10 @@ XMLDateTime* MonthDayDatatypeValidator::parse(const XMLCh* const content) { pRetDate->parseMonthDay(); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { delete pRetDate; diff --git a/src/xercesc/validators/datatype/NOTATIONDatatypeValidator.cpp b/src/xercesc/validators/datatype/NOTATIONDatatypeValidator.cpp index c42a4bb1b81ca57cf7d95ed4017bf3b62c9215fb..9bc9d8617c5a8095896ab8685125bb62e269dff6 100644 --- a/src/xercesc/validators/datatype/NOTATIONDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/NOTATIONDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/10/01 16:32:41 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.6 2003/09/30 21:31:30 peiyongz * Implementation of Serialization/Deserialization * @@ -112,6 +115,7 @@ #include <xercesc/util/XMLUri.hpp> #include <xercesc/validators/datatype/InvalidDatatypeFacetException.hpp> #include <xercesc/validators/datatype/InvalidDatatypeValueException.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -198,6 +202,10 @@ void NOTATIONDatatypeValidator::checkValueSpace(const XMLCh* const content) // no relative uri support here XMLUri newURI(uriPart, fMemoryManager); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { ThrowXML1(InvalidDatatypeValueException diff --git a/src/xercesc/validators/datatype/TimeDatatypeValidator.cpp b/src/xercesc/validators/datatype/TimeDatatypeValidator.cpp index 3db9153150f4676db8a7dadca04fd378ff099be4..d7120b6bc127df1d4d7a472e27ba1f0f57d737de 100644 --- a/src/xercesc/validators/datatype/TimeDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/TimeDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/10/01 16:32:41 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.6 2003/08/14 03:00:11 knoaman * Code refactoring to improve performance of validation. * @@ -90,6 +93,7 @@ // Includes // --------------------------------------------------------------------------- #include <xercesc/validators/datatype/TimeDatatypeValidator.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -136,6 +140,10 @@ XMLDateTime* TimeDatatypeValidator::parse(const XMLCh* const content) { pRetDate->parseTime(); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { delete pRetDate; diff --git a/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp b/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp index 2b49d55eaeb6db2050a7cbd27a97d547d4d50669..c051bb30d08ddfc8592421bc2b20ee8cf945a354 100644 --- a/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.12 2003/10/01 16:32:41 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.11 2003/08/16 18:42:49 neilg * fix for bug 22457. Union types that are restrictions of other union types were previously considered not to inherit their parents member types. This is at variance with the behaviour of the Java parser and apparently with the spec, so I have changed this. * @@ -114,6 +117,7 @@ #include <xercesc/validators/datatype/UnionDatatypeValidator.hpp> #include <xercesc/validators/datatype/InvalidDatatypeFacetException.hpp> #include <xercesc/validators/datatype/InvalidDatatypeValueException.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -198,6 +202,10 @@ UnionDatatypeValidator::UnionDatatypeValidator( { init(baseValidator, facets, enums); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { cleanUp(); diff --git a/src/xercesc/validators/datatype/YearDatatypeValidator.cpp b/src/xercesc/validators/datatype/YearDatatypeValidator.cpp index eb2fd253a1cf1170273a4c8950f55a32f2e6a184..f1b01368f458caf3893b67debb27608ccd9cd5a1 100644 --- a/src/xercesc/validators/datatype/YearDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/YearDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/10/01 16:32:41 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.6 2003/08/14 03:00:11 knoaman * Code refactoring to improve performance of validation. * @@ -90,6 +93,7 @@ // Includes // --------------------------------------------------------------------------- #include <xercesc/validators/datatype/YearDatatypeValidator.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -136,6 +140,10 @@ XMLDateTime* YearDatatypeValidator::parse(const XMLCh* const content) { pRetDate->parseYear(); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { delete pRetDate; diff --git a/src/xercesc/validators/datatype/YearMonthDatatypeValidator.cpp b/src/xercesc/validators/datatype/YearMonthDatatypeValidator.cpp index b83161c64cb8656c6148344d4575d6c3cfde1468..ec9b580d18e9920093fc201962055f5c100c808a 100644 --- a/src/xercesc/validators/datatype/YearMonthDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/YearMonthDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/10/01 16:32:41 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.6 2003/08/14 03:00:11 knoaman * Code refactoring to improve performance of validation. * @@ -90,6 +93,7 @@ // Includes // --------------------------------------------------------------------------- #include <xercesc/validators/datatype/YearMonthDatatypeValidator.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -136,6 +140,10 @@ XMLDateTime* YearMonthDatatypeValidator::parse(const XMLCh* const content) { pRetDate->parseYearMonth(); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { delete pRetDate; diff --git a/src/xercesc/validators/schema/GeneralAttributeCheck.cpp b/src/xercesc/validators/schema/GeneralAttributeCheck.cpp index 767bd2fd7dbf44d69083ad686bb57f4c62ecbfb1..6659699afffb749af240c690f638e77eebd00f64 100644 --- a/src/xercesc/validators/schema/GeneralAttributeCheck.cpp +++ b/src/xercesc/validators/schema/GeneralAttributeCheck.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.14 2003/10/01 16:32:41 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.13 2003/05/15 18:57:27 knoaman * Partial implementation of the configurable memory manager. * @@ -162,6 +165,7 @@ #include <xercesc/util/PlatformUtils.hpp> #include <xercesc/util/XMLRegisterCleanup.hpp> #include <xercesc/validators/datatype/DatatypeValidatorFactory.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -409,6 +413,10 @@ GeneralAttributeCheck::checkAttributes(const DOMElement* const elem, catch(const XMLException& excep) { schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, excep.getMessage()); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::InvalidAttValue, attrVal, attName); } @@ -427,6 +435,10 @@ GeneralAttributeCheck::checkAttributes(const DOMElement* const elem, try { attNameId= fAttMap->get(attName); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain, @@ -544,6 +556,10 @@ void GeneralAttributeCheck::validate(const DOMElement* const elem, catch(const XMLException& excep) { schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, excep.getMessage()); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { isInvalid = true; } diff --git a/src/xercesc/validators/schema/SchemaGrammar.cpp b/src/xercesc/validators/schema/SchemaGrammar.cpp index 23a133042f964364592908615e3fde35d479d83c..276e37ba6726eb4a1d362a7e33562ad9f04aa146 100644 --- a/src/xercesc/validators/schema/SchemaGrammar.cpp +++ b/src/xercesc/validators/schema/SchemaGrammar.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.9 2003/10/01 16:32:42 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.8 2003/09/22 19:49:02 neilg * implement change to Grammar::putElem(XMLElementDecl, bool). If Grammars are used only to hold declared objects, there will be no need for the fElemNonDeclPool tables; make Grammar implementations lazily create them only if the application requires them (which good cpplications should not.) * @@ -127,6 +130,7 @@ #include <xercesc/validators/schema/XercesGroupInfo.hpp> #include <xercesc/validators/schema/XercesAttGroupInfo.hpp> #include <xercesc/validators/schema/XMLSchemaDescriptionImpl.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -178,6 +182,10 @@ SchemaGrammar::SchemaGrammar(MemoryManager* const manager) : // reset(); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); diff --git a/src/xercesc/validators/schema/SchemaValidator.cpp b/src/xercesc/validators/schema/SchemaValidator.cpp index 2dba7697614ff5626a0b2f9dbfae27193cc83709..160b4ab3de2d8333680ade905a398a4dcf5859d2 100644 --- a/src/xercesc/validators/schema/SchemaValidator.cpp +++ b/src/xercesc/validators/schema/SchemaValidator.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.38 2003/10/01 16:32:42 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.37 2003/10/01 01:09:35 knoaman * Refactoring of some code to improve performance. * @@ -273,7 +276,7 @@ #include <xercesc/validators/schema/SubstitutionGroupComparator.hpp> #include <xercesc/validators/schema/XercesGroupInfo.hpp> #include <xercesc/validators/schema/XSDLocator.hpp> - +#include <xercesc/util/OutOfMemoryException.hpp> #include <xercesc/internal/XMLGrammarPoolImpl.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -556,6 +559,10 @@ int SchemaValidator::checkContent (XMLElementDecl* const elemDecl emitError (XMLValid::DatatypeError, idve.getType(), idve.getMessage()); valid = false; } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { ((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::INVALID); emitError(XMLValid::GenericError); @@ -765,6 +772,10 @@ void SchemaValidator::validateAttrValue (const XMLAttDef* attDef valid = false; emitError (XMLValid::DatatypeError, idve.getType(), idve.getMessage()); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { emitError(XMLValid::GenericError); ((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::INVALID); diff --git a/src/xercesc/validators/schema/TraverseSchema.cpp b/src/xercesc/validators/schema/TraverseSchema.cpp index 20aeb8a0b4e6b0849d6975998871759df0fb34d7..0806f3efd9c5fb6281773a02dacf4e4ac67c78f4 100644 --- a/src/xercesc/validators/schema/TraverseSchema.cpp +++ b/src/xercesc/validators/schema/TraverseSchema.cpp @@ -91,6 +91,7 @@ #include <xercesc/util/HashPtr.hpp> #include <xercesc/dom/DOMNamedNodeMap.hpp> #include <xercesc/dom/impl/XSDElementNSImpl.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -257,6 +258,10 @@ TraverseSchema::TraverseSchema( DOMElement* const schemaRoot } } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); @@ -2178,6 +2183,10 @@ void TraverseSchema::traverseAttributeDecl(const DOMElement* const elem, catch (const XMLException& excep) { reportSchemaError(elem, XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { reportSchemaError(elem, XMLUni::fgValidityDomain, XMLValid::DatatypeValidationFailure, valueToCheck); } @@ -2648,6 +2657,10 @@ QName* TraverseSchema::traverseElementDecl(const DOMElement* const elem, catch (const XMLException& excep) { reportSchemaError(elem, XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { reportSchemaError(elem, XMLUni::fgValidityDomain, XMLValid::DatatypeValidationFailure, deflt); } @@ -2920,6 +2933,10 @@ TraverseSchema::traverseByList(const DOMElement* const rootElem, catch (const XMLException& excep) { reportSchemaError(contentElem, XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { reportSchemaError(contentElem, XMLUni::fgXMLErrDomain, XMLErrs::DatatypeValidatorCreationError, typeName); @@ -3000,6 +3017,10 @@ TraverseSchema::traverseByRestriction(const DOMElement* const rootElem, try { scope = fAttributeCheck.getFacetId(facetName); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { reportSchemaError(content, XMLUni::fgXMLErrDomain, XMLErrs::InvalidFacetName, facetName); @@ -3105,6 +3126,10 @@ TraverseSchema::traverseByRestriction(const DOMElement* const rootElem, catch (const XMLException& excep) { reportSchemaError(contentElem, XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { reportSchemaError(contentElem, XMLUni::fgXMLErrDomain, XMLErrs::DatatypeValidatorCreationError, typeName); @@ -3211,6 +3236,10 @@ TraverseSchema::traverseByUnion(const DOMElement* const rootElem, catch (const XMLException& excep) { reportSchemaError(contentElem, XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { reportSchemaError(contentElem, XMLUni::fgXMLErrDomain, XMLErrs::DatatypeValidatorCreationError, typeName); @@ -3439,6 +3468,10 @@ void TraverseSchema::traverseSimpleContentDecl(const XMLCh* const typeName, try { scope = fAttributeCheck.getFacetId(facetName); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { break; } @@ -3529,6 +3562,10 @@ void TraverseSchema::traverseSimpleContentDecl(const XMLCh* const typeName, catch (const XMLException& excep) { reportSchemaError(simpleContent, XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { reportSchemaError(simpleContent, XMLUni::fgXMLErrDomain, XMLErrs::DatatypeValidatorCreationError, typeName); } @@ -5540,6 +5577,10 @@ void TraverseSchema::processAttributeDeclRef(const DOMElement* const elem, catch(const XMLException& excep) { reportSchemaError(elem, XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { reportSchemaError(elem, XMLUni::fgValidityDomain, XMLValid::DatatypeValidationFailure, valueConstraint); } @@ -5584,6 +5625,10 @@ void TraverseSchema::checkMinMax(ContentSpecNode* const specNode, try { minOccurs = XMLString::parseInt(minOccursStr); } + catch(const OutOfMemoryException&) + { + throw; + } catch (...) { minOccurs = 1; } @@ -5608,6 +5653,10 @@ void TraverseSchema::checkMinMax(ContentSpecNode* const specNode, try { maxOccurs = XMLString::parseInt(maxOccursStr); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { maxOccurs = minOccurs; } diff --git a/src/xercesc/validators/schema/identity/FieldValueMap.cpp b/src/xercesc/validators/schema/identity/FieldValueMap.cpp index 79987a19f328bf5cc614438d125df7b890e0a109..8dc958ee0b2925f231f3c529bcb7762f2d503f84 100644 --- a/src/xercesc/validators/schema/identity/FieldValueMap.cpp +++ b/src/xercesc/validators/schema/identity/FieldValueMap.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/10/01 16:32:42 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.6 2003/05/22 02:10:52 knoaman * Default the memory manager. * @@ -83,6 +86,7 @@ // Includes // --------------------------------------------------------------------------- #include <xercesc/validators/schema/identity/FieldValueMap.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -117,6 +121,10 @@ FieldValueMap::FieldValueMap(const FieldValueMap& other) } } } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { delete fFields; diff --git a/src/xercesc/validators/schema/identity/IdentityConstraint.cpp b/src/xercesc/validators/schema/identity/IdentityConstraint.cpp index 53bab02e1980a1894a5f38e020a14392dd5d407a..884a9ee9df2d118ad9b5c51b44b1b66f4a10ee21 100644 --- a/src/xercesc/validators/schema/identity/IdentityConstraint.cpp +++ b/src/xercesc/validators/schema/identity/IdentityConstraint.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.5 2003/10/01 16:32:42 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.4 2003/05/15 18:59:34 knoaman * Partial implementation of the configurable memory manager. * @@ -83,6 +86,7 @@ #include <xercesc/validators/schema/identity/IC_Selector.hpp> #include <xercesc/validators/schema/identity/IC_Field.hpp> #include <xercesc/util/XMLString.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -102,6 +106,10 @@ IdentityConstraint::IdentityConstraint(const XMLCh* const identityConstraintName fIdentityConstraintName = XMLString::replicate(identityConstraintName, fMemoryManager); fElemName = XMLString::replicate(elemName, fMemoryManager); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); diff --git a/src/xercesc/validators/schema/identity/ValueStoreCache.cpp b/src/xercesc/validators/schema/identity/ValueStoreCache.cpp index c135fe131ec4ed489da97b95f339b48b9443b330..2874d762e56b532404d6c5aef22b689e6e9d33d7 100644 --- a/src/xercesc/validators/schema/identity/ValueStoreCache.cpp +++ b/src/xercesc/validators/schema/identity/ValueStoreCache.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.9 2003/10/01 16:32:42 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.8 2003/05/26 22:05:01 knoaman * Pass the memory manager to XMLString::replicate. * @@ -92,6 +95,7 @@ #include <xercesc/validators/schema/identity/ValueStore.hpp> #include <xercesc/validators/schema/SchemaElementDecl.hpp> #include <xercesc/util/HashPtr.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -109,6 +113,10 @@ ValueStoreCache::ValueStoreCache(MemoryManager* const manager) try { init(); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); throw; diff --git a/src/xercesc/validators/schema/identity/XPathMatcher.cpp b/src/xercesc/validators/schema/identity/XPathMatcher.cpp index df72a352fbe154106c54b5cf6a0e5b5bf23b2072..eff426d320503ea6a68cae0f01266f91bb132925 100644 --- a/src/xercesc/validators/schema/identity/XPathMatcher.cpp +++ b/src/xercesc/validators/schema/identity/XPathMatcher.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.9 2003/10/01 16:32:42 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.8 2003/05/18 14:02:09 knoaman * Memory manager implementation: pass per instance manager. * @@ -97,6 +100,7 @@ #include <xercesc/validators/schema/SchemaAttDef.hpp> #include <xercesc/validators/schema/SchemaSymbols.hpp> #include <xercesc/util/RuntimeException.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -117,6 +121,10 @@ XPathMatcher::XPathMatcher( XercesXPath* const xpath try { init(xpath); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); @@ -140,6 +148,10 @@ XPathMatcher::XPathMatcher(XercesXPath* const xpath, try { init(xpath); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp(); diff --git a/src/xercesc/validators/schema/identity/XPathMatcherStack.cpp b/src/xercesc/validators/schema/identity/XPathMatcherStack.cpp index 0c7bb9b2fab0334c14c214742d21f044a2c63cdb..9af2b5cdbede7f659d68c8581071094c9f2a37b9 100644 --- a/src/xercesc/validators/schema/identity/XPathMatcherStack.cpp +++ b/src/xercesc/validators/schema/identity/XPathMatcherStack.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.5 2003/10/01 16:32:42 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.4 2003/05/18 14:02:09 knoaman * Memory manager implementation: pass per instance manager. * @@ -77,6 +80,7 @@ // Includes // --------------------------------------------------------------------------- #include <xercesc/validators/schema/identity/XPathMatcherStack.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -91,6 +95,10 @@ XPathMatcherStack::XPathMatcherStack(MemoryManager* const manager) try { fMatchers = new (manager) RefVectorOf<XPathMatcher>(8, true, manager); } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { delete fContextStack; diff --git a/src/xercesc/validators/schema/identity/XercesXPath.cpp b/src/xercesc/validators/schema/identity/XercesXPath.cpp index e61670857f82eee53af8759dcad55acd4242dfc7..d5fa7586f406a1ab3bc029159b340fe846ef4c2f 100644 --- a/src/xercesc/validators/schema/identity/XercesXPath.cpp +++ b/src/xercesc/validators/schema/identity/XercesXPath.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.9 2003/10/01 16:32:42 neilg + * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. + * * Revision 1.8 2003/05/18 14:02:09 knoaman * Memory manager implementation: pass per instance manager. * @@ -103,6 +106,7 @@ #include <xercesc/framework/XMLBuffer.hpp> #include <xercesc/internal/XMLReader.hpp> #include <xercesc/util/RuntimeException.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -290,6 +294,10 @@ XercesXPath::XercesXPath(const XMLCh* const xpathExpr, checkForSelectedAttributes(); } } + catch(const OutOfMemoryException&) + { + throw; + } catch(...) { cleanUp();