You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ca...@apache.org on 2005/06/21 20:16:35 UTC

svn commit: r191701 - in /xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity: FieldValueMap.cpp IdentityConstraint.cpp IdentityConstraintHandler.cpp ValueStoreCache.cpp XPathMatcher.cpp XPathMatcherStack.cpp XercesXPath.cpp

Author: cargilld
Date: Tue Jun 21 11:16:34 2005
New Revision: 191701

URL: http://svn.apache.org/viewcvs?rev=191701&view=rev
Log:
Add back changes Bertoni made that were overwritten.

Modified:
    xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/FieldValueMap.cpp
    xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/IdentityConstraint.cpp
    xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/IdentityConstraintHandler.cpp
    xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/ValueStoreCache.cpp
    xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/XPathMatcher.cpp
    xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/XPathMatcherStack.cpp
    xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/XercesXPath.cpp

Modified: xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/FieldValueMap.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/FieldValueMap.cpp?rev=191701&r1=191700&r2=191701&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/FieldValueMap.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/FieldValueMap.cpp Tue Jun 21 11:16:34 2005
@@ -22,10 +22,13 @@
 //  Includes
 // ---------------------------------------------------------------------------
 #include <xercesc/validators/schema/identity/FieldValueMap.hpp>
+#include <xercesc/util/Janitor.hpp>
 #include <xercesc/util/OutOfMemoryException.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
+typedef JanitorMemFunCall<FieldValueMap>    CleanupType;
+
 // ---------------------------------------------------------------------------
 //  FieldValueMap: Constructors and Destructor
 // ---------------------------------------------------------------------------
@@ -44,34 +47,41 @@
     , fValues(0)
     , fMemoryManager(other.fMemoryManager)
 {
-    try {
-        if (other.fFields) {
+    if (other.fFields) {
+        CleanupType cleanup(this, &FieldValueMap::cleanUp);
+
+        try {
+
+                unsigned int valuesSize = other.fValues->size();
 
-            unsigned int valuesSize = other.fValues->size();
+                fFields = new (fMemoryManager) ValueVectorOf<IC_Field*>(*(other.fFields));
+                fValidators = new (fMemoryManager) ValueVectorOf<DatatypeValidator*>(*(other.fValidators));
+                fValues = new (fMemoryManager) RefArrayVectorOf<XMLCh>(other.fFields->curCapacity(), true, fMemoryManager);
 
-            fFields = new (fMemoryManager) ValueVectorOf<IC_Field*>(*(other.fFields));
-            fValidators = new (fMemoryManager) ValueVectorOf<DatatypeValidator*>(*(other.fValidators));
-            fValues = new (fMemoryManager) RefArrayVectorOf<XMLCh>(other.fFields->curCapacity(), true, fMemoryManager);
-
-            for (unsigned int i=0; i<valuesSize; i++) {
-                fValues->addElement(XMLString::replicate(other.fValues->elementAt(i), fMemoryManager));
-            }
+                for (unsigned int i=0; i<valuesSize; i++) {
+                    fValues->addElement(XMLString::replicate(other.fValues->elementAt(i), fMemoryManager));
+                }
+        }
+        catch(const OutOfMemoryException&)
+        {
+            cleanup.release();
+
+            throw;
         }
-    }
-    catch(const OutOfMemoryException&)
-    {
-        throw;
-    }
-    catch(...) {
 
-        delete fFields;
-        delete fValidators;
-        delete fValues;
-        throw;
+        cleanup.release();
     }
 }
 
 FieldValueMap::~FieldValueMap()
+{
+    cleanUp();
+}
+
+// ---------------------------------------------------------------------------
+//  FieldValueMap: Private helper methods.
+// ---------------------------------------------------------------------------
+void FieldValueMap::cleanUp()
 {
     delete fFields;
     delete fValidators;

Modified: xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/IdentityConstraint.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/IdentityConstraint.cpp?rev=191701&r1=191700&r2=191701&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/IdentityConstraint.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/IdentityConstraint.cpp Tue Jun 21 11:16:34 2005
@@ -38,6 +38,8 @@
 
 XERCES_CPP_NAMESPACE_BEGIN
 
+typedef JanitorMemFunCall<IdentityConstraint>   CleanupType;
+
 // ---------------------------------------------------------------------------
 //  IdentityConstraint: Constructors and Destructor
 // ---------------------------------------------------------------------------
@@ -51,19 +53,20 @@
     , fMemoryManager(manager)
     , fNamespaceURI(-1)
 {
+    CleanupType cleanup(this, &IdentityConstraint::cleanUp);
+
     try {
         fIdentityConstraintName = XMLString::replicate(identityConstraintName, fMemoryManager);
         fElemName = XMLString::replicate(elemName, fMemoryManager);
     }
     catch(const OutOfMemoryException&)
     {
-        throw;
-    }
-    catch(...) {
+        cleanup.release();
 
-        cleanUp();
         throw;
     }
+
+    cleanup.release();
 }
 
 

Modified: xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/IdentityConstraintHandler.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/IdentityConstraintHandler.cpp?rev=191701&r1=191700&r2=191701&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/IdentityConstraintHandler.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/IdentityConstraintHandler.cpp Tue Jun 21 11:16:34 2005
@@ -33,6 +33,8 @@
 
 XERCES_CPP_NAMESPACE_BEGIN
 
+typedef JanitorMemFunCall<IdentityConstraintHandler>    CleanupType;
+
 // ---------------------------------------------------------------------------
 //  IdentityConstraintHandler: Constructors and Destructor
 // ---------------------------------------------------------------------------
@@ -44,6 +46,7 @@
 , fValueStoreCache(0)
 , fFieldActivator(0)
 {
+    CleanupType cleanup(this, &IdentityConstraintHandler::cleanUp);
 
     try {
 
@@ -55,12 +58,12 @@
     }
     catch(const OutOfMemoryException&)
     {
+        cleanup.release();
+
         throw;
     }
-    catch(...) {
-        cleanUp();
-        throw;
-    }
+
+    cleanup.release();
 }
 
 IdentityConstraintHandler::~IdentityConstraintHandler()

Modified: xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/ValueStoreCache.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/ValueStoreCache.cpp?rev=191701&r1=191700&r2=191701&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/ValueStoreCache.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/ValueStoreCache.cpp Tue Jun 21 11:16:34 2005
@@ -29,6 +29,8 @@
 
 XERCES_CPP_NAMESPACE_BEGIN
 
+typedef JanitorMemFunCall<ValueStoreCache>    CleanupType;
+
 // ---------------------------------------------------------------------------
 //  ValueStoreCache: Constructors and Destructor
 // ---------------------------------------------------------------------------
@@ -40,17 +42,19 @@
     , fScanner(0)
     , fMemoryManager(manager)
 {
+    CleanupType cleanup(this, &ValueStoreCache::cleanUp);
+
     try {
         init();
     }
     catch(const OutOfMemoryException&)
     {
+        cleanup.release();
+
         throw;
     }
-    catch(...) {
-        cleanUp();
-        throw;
-    }
+
+    cleanup.release();
 }
 
 

Modified: xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/XPathMatcher.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/XPathMatcher.cpp?rev=191701&r1=191700&r2=191701&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/XPathMatcher.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/XPathMatcher.cpp Tue Jun 21 11:16:34 2005
@@ -31,6 +31,8 @@
 
 XERCES_CPP_NAMESPACE_BEGIN
 
+typedef JanitorMemFunCall<XPathMatcher>     CleanupType;
+
 // ---------------------------------------------------------------------------
 //  XPathMatcher: Constructors and Destructor
 // ---------------------------------------------------------------------------
@@ -45,18 +47,19 @@
     , fIdentityConstraint(0)
     , fMemoryManager(manager)
 {
+    CleanupType cleanup(this, &XPathMatcher::cleanUp);
+
     try {
         init(xpath);
     }
     catch(const OutOfMemoryException&)
     {
-        throw;
-    }
-    catch(...) {
+        cleanup.release();
 
-        cleanUp();
         throw;
     }
+
+    cleanup.release();
 }
 
 
@@ -72,18 +75,19 @@
     , fIdentityConstraint(ic)
     , fMemoryManager(manager)
 {
+    CleanupType cleanup(this, &XPathMatcher::cleanUp);
+
     try {
         init(xpath);
     }
     catch(const OutOfMemoryException&)
     {
-        throw;
-    }
-    catch(...) {
+        cleanup.release();
 
-        cleanUp();
         throw;
     }
+
+    cleanup.release();
 }
 
 

Modified: xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/XPathMatcherStack.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/XPathMatcherStack.cpp?rev=191701&r1=191700&r2=191701&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/XPathMatcherStack.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/XPathMatcherStack.cpp Tue Jun 21 11:16:34 2005
@@ -22,34 +22,47 @@
 //  Includes
 // ---------------------------------------------------------------------------
 #include <xercesc/validators/schema/identity/XPathMatcherStack.hpp>
+#include <xercesc/util/Janitor.hpp>
 #include <xercesc/util/OutOfMemoryException.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
+typedef JanitorMemFunCall<XPathMatcherStack>    CleanupType;
+
 // ---------------------------------------------------------------------------
 //  XPathMatherStack: Constructors and Destructor
 // ---------------------------------------------------------------------------
 XPathMatcherStack::XPathMatcherStack(MemoryManager* const manager)
     : fMatchersCount(0)
-    , fContextStack(new (manager) ValueStackOf<int>(8, manager))
+    , fContextStack(0)
     , fMatchers(0)
 {
+    CleanupType cleanup(this, &XPathMatcherStack::cleanUp);
+
     try {
+        fContextStack = new (manager) ValueStackOf<int>(8, manager);
         fMatchers = new (manager) RefVectorOf<XPathMatcher>(8, true, manager);
     }
     catch(const OutOfMemoryException&)
     {
-        throw;
-    }
-    catch(...) {
+        cleanup.release();
 
-        delete fContextStack;
         throw;
     }
+
+    cleanup.release();
 }
 
 XPathMatcherStack::~XPathMatcherStack() {
 
+    cleanUp();
+}
+
+// ---------------------------------------------------------------------------
+//  XPathMatcherStack: Private helper methods.
+// ---------------------------------------------------------------------------
+void XPathMatcherStack::cleanUp()
+{
     delete fContextStack;
     delete fMatchers;
 }

Modified: xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/XercesXPath.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/XercesXPath.cpp?rev=191701&r1=191700&r2=191701&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/XercesXPath.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/identity/XercesXPath.cpp Tue Jun 21 11:16:34 2005
@@ -286,6 +286,8 @@
 {
 }
 
+typedef JanitorMemFunCall<XercesXPath>  CleanupType;
+
 // ---------------------------------------------------------------------------
 //  XercesPath: Constructors and Destructor
 // ---------------------------------------------------------------------------
@@ -300,6 +302,8 @@
     , fLocationPaths(0)
     , fMemoryManager(manager)
 {
+    CleanupType cleanup(this, &XercesXPath::cleanUp);
+
     try
     {
         fExpression = XMLString::replicate(xpathExpr, fMemoryManager);
@@ -311,13 +315,12 @@
     }
     catch(const OutOfMemoryException&)
     {
-        throw;
-    }
-    catch(...) {
+        cleanup.release();
 
-        cleanUp();
         throw;
     }
+
+    cleanup.release();
 }
 
 XercesXPath::~XercesXPath() {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org