Author: cargilld
Date: Thu Oct 5 12:47:32 2006
New Revision: 453334
URL: http://svn.apache.org/viewvc?view=rev&rev=453334
Log:
Use local memory manager for thread safety.
Modified:
xerces/c/branches/xerces-2.7/src/xercesc/validators/common/AllContentModel.cpp
Modified:
xerces/c/branches/xerces-2.7/src/xercesc/validators/common/AllContentModel.cpp
URL:
http://svn.apache.org/viewvc/xerces/c/branches/xerces-2.7/src/xercesc/validators/common/AllContentModel.cpp?view=diff&rev=453334&r1=453333&r2=453334
==============================================================================
---
xerces/c/branches/xerces-2.7/src/xercesc/validators/common/AllContentModel.cpp
(original)
+++
xerces/c/branches/xerces-2.7/src/xercesc/validators/common/AllContentModel.cpp
Thu Oct 5 12:47:32 2006
@@ -22,6 +22,7 @@
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
+#include <xercesc/util/Janitor.hpp>
#include <xercesc/util/RuntimeException.hpp>
#include <xercesc/framework/XMLElementDecl.hpp>
#include <xercesc/framework/XMLValidator.hpp>
@@ -112,8 +113,13 @@
if (childCount == 0 && (fHasOptionalContent || !fNumRequired))
return -1;
+ MemoryManager* const localMemoryManager =
+ children[0]->getMemoryManager();
+
// Check for duplicate element
- bool* elementSeen = (bool*) fMemoryManager->allocate(fCount*sizeof(bool));
//new bool[fCount];
+ bool* elementSeen = (bool*)
localMemoryManager->allocate(fCount*sizeof(bool)); //new bool[fCount];
+
+ const ArrayJanitor<bool> jan(elementSeen, localMemoryManager);
// initialize the array
for (unsigned int i = 0; i < fCount; i++)
@@ -126,7 +132,7 @@
// Get the current child out of the source index
const QName* curChild = children[outIndex];
- // If its PCDATA, then we just accept that
+ // If it's PCDATA, then we just accept that
if (fIsMixed && curChild->getURI() == XMLElementDecl::fgPCDataElemId)
continue;
@@ -141,7 +147,6 @@
// If this element was seen already, indicate an error was
// found at the duplicate index.
if (elementSeen[inIndex]) {
- fMemoryManager->deallocate(elementSeen); //delete []
elementSeen;
return outIndex;
}
else
@@ -156,21 +161,17 @@
// We did not find this one, so the validation failed
if (inIndex == fCount) {
- fMemoryManager->deallocate(elementSeen); //delete [] elementSeen;
return outIndex;
}
}
- fMemoryManager->deallocate(elementSeen); //delete [] elementSeen;
-
// Were all the required elements of the <all> encountered?
if (numRequiredSeen != fNumRequired) {
return childCount;
}
// Everything seems to be ok, so return success
- // success
return -1;
}
@@ -189,8 +190,13 @@
if (childCount == 0 && (fHasOptionalContent || !fNumRequired))
return -1;
+ MemoryManager* const localMemoryManager =
+ children[0]->getMemoryManager();
+
// Check for duplicate element
- bool* elementSeen = (bool*) fMemoryManager->allocate(fCount*sizeof(bool));
//new bool[fCount];
+ bool* elementSeen = (bool*)
localMemoryManager->allocate(fCount*sizeof(bool)); //new bool[fCount];
+
+ const ArrayJanitor<bool> jan(elementSeen, localMemoryManager);
// initialize the array
for (unsigned int i = 0; i < fCount; i++)
@@ -203,7 +209,7 @@
// Get the current child out of the source index
QName* const curChild = children[outIndex];
- // If its PCDATA, then we just accept that
+ // If it's PCDATA, then we just accept that
if (fIsMixed && curChild->getURI() == XMLElementDecl::fgPCDataElemId)
continue;
@@ -217,7 +223,6 @@
// If this element was seen already, indicate an error was
// found at the duplicate index.
if (elementSeen[inIndex]) {
- fMemoryManager->deallocate(elementSeen); //delete []
elementSeen;
return outIndex;
}
else
@@ -232,21 +237,17 @@
// We did not find this one, so the validation failed
if (inIndex == fCount) {
- fMemoryManager->deallocate(elementSeen); //delete [] elementSeen;
return outIndex;
}
}
- fMemoryManager->deallocate(elementSeen); //delete [] elementSeen;
-
// Were all the required elements of the <all> encountered?
if (numRequiredSeen != fNumRequired) {
return childCount;
}
// Everything seems to be ok, so return success
- // success
return -1;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]