You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by tn...@apache.org on 2001/10/03 17:49:02 UTC
cvs commit: xml-xerces/c/tests/IThreadTest IThreadTest.cpp
tng 01/10/03 08:49:01
Modified: c/samples/IDOMPrint IDOMPrint.cpp
c/src/idom IDDeepNodeListImpl.cpp IDDeepNodeListImpl.hpp
IDDocumentImpl.cpp IDDocumentImpl.hpp
IDElementImpl.cpp
c/tests/IThreadTest IThreadTest.cpp
Log:
[Bug 3867] IDOM_Element::getElementsByTagName() threading problem.
Revision Changes Path
1.5 +1 -2 xml-xerces/c/samples/IDOMPrint/IDOMPrint.cpp
Index: IDOMPrint.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/samples/IDOMPrint/IDOMPrint.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- IDOMPrint.cpp 2001/08/01 19:11:01 1.4
+++ IDOMPrint.cpp 2001/10/03 15:49:01 1.5
@@ -55,7 +55,7 @@
*/
/*
- * $Id: IDOMPrint.cpp,v 1.4 2001/08/01 19:11:01 tng Exp $
+ * $Id: IDOMPrint.cpp,v 1.5 2001/10/03 15:49:01 tng Exp $
*/
@@ -513,7 +513,6 @@
retval = 3;
}
- delete doc;
delete formatTarget;
delete gFormatter;
}
1.7 +3 -38 xml-xerces/c/src/idom/IDDeepNodeListImpl.cpp
Index: IDDeepNodeListImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/idom/IDDeepNodeListImpl.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- IDDeepNodeListImpl.cpp 2001/08/09 16:52:59 1.6
+++ IDDeepNodeListImpl.cpp 2001/10/03 15:49:01 1.7
@@ -56,6 +56,9 @@
/*
* $Log: IDDeepNodeListImpl.cpp,v $
+ * Revision 1.7 2001/10/03 15:49:01 tng
+ * [Bug 3867] IDOM_Element::getElementsByTagName() threading problem.
+ *
* Revision 1.6 2001/08/09 16:52:59 tng
* [Bug 2947] IDOM segfault calling getElementsByTagName() using a DOM_Document().
*
@@ -85,7 +88,6 @@
#include <limits.h>
static const XMLCh kAstr[] = {chAsterisk, chNull};
-IDDeepNodeListPool<IDDeepNodeListImpl>* IDDeepNodeListImpl::fNodeListPool = 0;
IDDeepNodeListImpl::IDDeepNodeListImpl(const IDOM_Node *rootNode,
const XMLCh *tagName)
@@ -123,43 +125,6 @@
IDDeepNodeListImpl::~IDDeepNodeListImpl()
{
}
-
-
-IDOM_NodeList *IDDeepNodeListImpl::getDeepNodeList(const IDOM_Node *rootNode, const XMLCh *tagName)
-{
- if(!fNodeListPool) {
- fNodeListPool = new ((IDDocumentImpl *)(castToNodeImpl(rootNode)->getOwnerDocument())) IDDeepNodeListPool<IDDeepNodeListImpl>(109);
- }
-
- IDDeepNodeListImpl* retList = fNodeListPool->getByKey(rootNode, tagName, 0);
- if (!retList) {
- // the pool will adopt the IDDeepNodeListImpl
- int id = fNodeListPool->put((void*) rootNode, (XMLCh*) tagName, 0, new IDDeepNodeListImpl(rootNode, tagName));
- retList = fNodeListPool->getById(id);
- }
-
- return retList;
-}
-
-
-IDOM_NodeList *IDDeepNodeListImpl::getDeepNodeList(const IDOM_Node *rootNode, //DOM Level 2
- const XMLCh *namespaceURI,
- const XMLCh *localName)
-{
- if(!fNodeListPool) {
- fNodeListPool = new ((IDDocumentImpl *)(castToNodeImpl(rootNode)->getOwnerDocument())) IDDeepNodeListPool<IDDeepNodeListImpl>(109);
- }
-
- IDDeepNodeListImpl* retList = fNodeListPool->getByKey(rootNode, localName, namespaceURI);
- if (!retList) {
- // the pool will adopt the IDDeepNodeListImpl
- int id = fNodeListPool->put((void*) rootNode, (XMLCh*) localName, (XMLCh*) namespaceURI, new IDDeepNodeListImpl(rootNode, namespaceURI, localName));
- retList = fNodeListPool->getById(id);
- }
-
- return retList;
-}
-
unsigned int IDDeepNodeListImpl::getLength()
{
1.4 +7 -18 xml-xerces/c/src/idom/IDDeepNodeListImpl.hpp
Index: IDDeepNodeListImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/idom/IDDeepNodeListImpl.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IDDeepNodeListImpl.hpp 2001/06/04 14:55:32 1.3
+++ IDDeepNodeListImpl.hpp 2001/10/03 15:49:01 1.4
@@ -59,6 +59,9 @@
/*
* $Log: IDDeepNodeListImpl.hpp,v $
+ * Revision 1.4 2001/10/03 15:49:01 tng
+ * [Bug 3867] IDOM_Element::getElementsByTagName() threading problem.
+ *
* Revision 1.3 2001/06/04 14:55:32 tng
* IDOM: Add IRange and IDeepNodeList Support.
*
@@ -80,7 +83,6 @@
//
#include <util/XercesDefs.hpp>
-#include "IDDeepNodeListPool.hpp"
#include "IDOM_NodeList.hpp"
class IDOM_Node;
@@ -100,30 +102,17 @@
bool fMatchAllURI;
bool fMatchURIandTagname; //match both namespaceURI and tagName
-private:
+public:
IDDeepNodeListImpl(const IDOM_Node *rootNode, const XMLCh *tagName);
IDDeepNodeListImpl(const IDOM_Node *rootNode, //DOM Level 2
const XMLCh *namespaceURI,
const XMLCh *localName);
- IDOM_Node * nextMatchingElementAfter(IDOM_Node *current);
-
-public:
- // Factory methods for getting/creating node lists.
- // Because nothing is ever deleted, the implementation caches and recycles
- // previously used instances of IDDeepNodeList
- //
- static IDOM_NodeList *getDeepNodeList(const IDOM_Node *rootNode, const XMLCh *tagName);
- static IDOM_NodeList *getDeepNodeList(const IDOM_Node *rootNode, //DOM Level 2
- const XMLCh *namespaceURI,
- const XMLCh *localName);
-
-private:
- static IDDeepNodeListPool<IDDeepNodeListImpl> *fNodeListPool;
-
-public:
virtual ~IDDeepNodeListImpl();
virtual unsigned int getLength();
virtual IDOM_Node *item(unsigned int index);
+
+private:
+ IDOM_Node * nextMatchingElementAfter(IDOM_Node *current);
};
#endif
1.10 +42 -3 xml-xerces/c/src/idom/IDDocumentImpl.cpp
Index: IDDocumentImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/idom/IDDocumentImpl.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- IDDocumentImpl.cpp 2001/08/07 15:34:54 1.9
+++ IDDocumentImpl.cpp 2001/10/03 15:49:01 1.10
@@ -55,7 +55,7 @@
*/
/*
- * $Id: IDDocumentImpl.cpp,v 1.9 2001/08/07 15:34:54 tng Exp $
+ * $Id: IDDocumentImpl.cpp,v 1.10 2001/10/03 15:49:01 tng Exp $
*/
#include <util/XMLUniDefs.hpp>
@@ -122,6 +122,7 @@
fUserData = 0;
fRanges = 0;
fChanges = 0;
+ fNodeListPool = 0;
};
@@ -145,6 +146,7 @@
fUserData = 0;
fRanges = 0;
fChanges = 0;
+ fNodeListPool = 0;
}
void IDDocumentImpl::setDocumentType(IDOM_DocumentType *doctype)
@@ -404,7 +406,8 @@
IDOM_NodeList *IDDocumentImpl::getElementsByTagName(const XMLCh *tagname) const
{
- return IDDeepNodeListImpl::getDeepNodeList(this,tagname);
+ // cast off the const of this because we will update the fNodeListPool
+ return ((IDDocumentImpl*)this)->getDeepNodeList(this,tagname);
};
@@ -635,7 +638,8 @@
IDOM_NodeList *IDDocumentImpl::getElementsByTagNameNS(const XMLCh *fNamespaceURI,
const XMLCh *fLocalName) const
{
- return IDDeepNodeListImpl::getDeepNodeList(this, fNamespaceURI, fLocalName);
+ // cast off the const of this because we will update the fNodeListPool
+ return ((IDDocumentImpl*)this)->getDeepNodeList(this, fNamespaceURI, fLocalName);
}
@@ -933,3 +937,38 @@
}
}
+
+IDOM_NodeList *IDDocumentImpl::getDeepNodeList(const IDOM_Node *rootNode, const XMLCh *tagName)
+{
+ if(!fNodeListPool) {
+ fNodeListPool = new IDDeepNodeListPool<IDDeepNodeListImpl>(109, false);
+ }
+
+ IDDeepNodeListImpl* retList = fNodeListPool->getByKey(rootNode, tagName, 0);
+ if (!retList) {
+ int id = fNodeListPool->put((void*) rootNode, (XMLCh*) tagName, 0, new (this) IDDeepNodeListImpl(rootNode, tagName));
+ retList = fNodeListPool->getById(id);
+ }
+
+ return retList;
+}
+
+
+IDOM_NodeList *IDDocumentImpl::getDeepNodeList(const IDOM_Node *rootNode, //DOM Level 2
+ const XMLCh *namespaceURI,
+ const XMLCh *localName)
+{
+ if(!fNodeListPool) {
+ fNodeListPool = new (this) IDDeepNodeListPool<IDDeepNodeListImpl>(109, false);
+ }
+
+ IDDeepNodeListImpl* retList = fNodeListPool->getByKey(rootNode, localName, namespaceURI);
+ if (!retList) {
+ // the pool will adopt the IDDeepNodeListImpl
+ int id = fNodeListPool->put((void*) rootNode, (XMLCh*) localName, (XMLCh*) namespaceURI, new (this) IDDeepNodeListImpl(rootNode, namespaceURI, localName));
+ retList = fNodeListPool->getById(id);
+ }
+
+ return retList;
+}
+
1.11 +15 -1 xml-xerces/c/src/idom/IDDocumentImpl.hpp
Index: IDDocumentImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/idom/IDDocumentImpl.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- IDDocumentImpl.hpp 2001/06/08 21:23:02 1.10
+++ IDDocumentImpl.hpp 2001/10/03 15:49:01 1.11
@@ -58,7 +58,7 @@
*/
/*
- * $Id: IDDocumentImpl.hpp,v 1.10 2001/06/08 21:23:02 tng Exp $
+ * $Id: IDDocumentImpl.hpp,v 1.11 2001/10/03 15:49:01 tng Exp $
*/
//
@@ -78,6 +78,7 @@
#include "IDOM_Document.hpp"
#include "IDNodeImpl.hpp"
#include "IDParentNode.hpp"
+#include "IDDeepNodeListPool.hpp"
class IDAttrImpl;
@@ -284,6 +285,19 @@
XMLCh * cloneString(const XMLCh *src);
const XMLCh * getPooledString(const XMLCh *src);
void deleteHeap();
+
+
+ // Factory methods for getting/creating node lists.
+ // Because nothing is ever deleted, the implementation caches and recycles
+ // previously used instances of IDDeepNodeList
+ //
+ IDOM_NodeList *getDeepNodeList(const IDOM_Node *rootNode, const XMLCh *tagName);
+ IDOM_NodeList *getDeepNodeList(const IDOM_Node *rootNode, //DOM Level 2
+ const XMLCh *namespaceURI,
+ const XMLCh *localName);
+
+private:
+ IDDeepNodeListPool<IDDeepNodeListImpl> *fNodeListPool;
};
//
1.4 +5 -3 xml-xerces/c/src/idom/IDElementImpl.cpp
Index: IDElementImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/idom/IDElementImpl.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IDElementImpl.cpp 2001/06/04 14:55:33 1.3
+++ IDElementImpl.cpp 2001/10/03 15:49:01 1.4
@@ -55,7 +55,7 @@
*/
/*
- * $Id: IDElementImpl.cpp,v 1.3 2001/06/04 14:55:33 tng Exp $
+ * $Id: IDElementImpl.cpp,v 1.4 2001/10/03 15:49:01 tng Exp $
*/
#include "IDElementImpl.hpp"
@@ -164,7 +164,8 @@
IDOM_NodeList *IDElementImpl::getElementsByTagName(const XMLCh *tagname) const
{
- return IDDeepNodeListImpl::getDeepNodeList(this,tagname);
+ IDDocumentImpl *docImpl = (IDDocumentImpl *)getOwnerDocument();
+ return docImpl->getDeepNodeList(this,tagname);
};
@@ -329,7 +330,8 @@
IDOM_NodeList *IDElementImpl::getElementsByTagNameNS(const XMLCh *namespaceURI,
const XMLCh *localName) const
{
- return IDDeepNodeListImpl::getDeepNodeList(this, namespaceURI, localName);
+ IDDocumentImpl *docImpl = (IDDocumentImpl *)getOwnerDocument();;
+ return docImpl->getDeepNodeList(this, namespaceURI, localName);
}
// DOM_NamedNodeMap UTILITIES
1.5 +1 -4 xml-xerces/c/tests/IThreadTest/IThreadTest.cpp
Index: IThreadTest.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/tests/IThreadTest/IThreadTest.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- IThreadTest.cpp 2001/06/22 14:21:56 1.4
+++ IThreadTest.cpp 2001/10/03 15:49:01 1.5
@@ -55,7 +55,7 @@
*/
/*
-* $Id: IThreadTest.cpp,v 1.4 2001/06/22 14:21:56 tng Exp $
+* $Id: IThreadTest.cpp,v 1.5 2001/10/03 15:49:01 tng Exp $
*/
#include <stdlib.h>
@@ -370,7 +370,6 @@
ThreadParser::~ThreadParser()
{
- delete fDoc;
delete fSAXParser;
delete fDOMParser;
}
@@ -388,8 +387,6 @@
{
MemBufInputSource *mbis = 0;
InFileInfo *fInfo = &gRunInfo.files[fileNum];
- delete fDoc;
- fDoc = 0;
fCheckSum = 0;
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org