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/05/23 15:11:45 UTC
cvs commit: xml-xerces/c/src/idom IDAttrImpl.cpp IDAttrNSImpl.cpp IDDOMImplementation.cpp IDDocumentImpl.cpp IDDocumentImpl.hpp IDElementNSImpl.cpp IDNodeIDMap.cpp IDNodeVector.cpp IDStringPool.cpp
tng 01/05/23 06:11:44
Modified: c/src/idom IDAttrImpl.cpp IDAttrNSImpl.cpp
IDDOMImplementation.cpp IDDocumentImpl.cpp
IDDocumentImpl.hpp IDElementNSImpl.cpp
IDNodeIDMap.cpp IDNodeVector.cpp IDStringPool.cpp
Log:
IDOM: Memory fix.
Revision Changes Path
1.4 +3 -6 xml-xerces/c/src/idom/IDAttrImpl.cpp
Index: IDAttrImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/idom/IDAttrImpl.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IDAttrImpl.cpp 2001/05/17 15:58:28 1.3
+++ IDAttrImpl.cpp 2001/05/23 13:11:35 1.4
@@ -55,7 +55,7 @@
*/
/*
- * $Id: IDAttrImpl.cpp,v 1.3 2001/05/17 15:58:28 tng Exp $
+ * $Id: IDAttrImpl.cpp,v 1.4 2001/05/23 13:11:35 tng Exp $
*/
#include "IDAttrImpl.hpp"
@@ -153,17 +153,14 @@
// becuase we only allocate a new string when we have attribute
// values that contain entity reference nodes. And the parser
// does not ever produce such a thing.
- XMLCh* retString = new XMLCh(length+1);
+ XMLCh * retString = new (this->getOwnerDocument()) XMLCh[length+1];
retString[0] = 0;
for (node = fParent.fFirstChild; node != 0; node = castToChildImpl(node)->nextSibling)
{
XMLString::catString(retString, node->getNodeValue());
};
- IDDocumentImpl *docImpl = (IDDocumentImpl *)getOwnerDocument();
- const XMLCh* temp = docImpl->getPooledString(retString);
- delete retString;
- return temp;
+ return retString;
};
1.4 +3 -7 xml-xerces/c/src/idom/IDAttrNSImpl.cpp
Index: IDAttrNSImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/idom/IDAttrNSImpl.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IDAttrNSImpl.cpp 2001/05/16 14:30:21 1.3
+++ IDAttrNSImpl.cpp 2001/05/23 13:11:36 1.4
@@ -55,7 +55,7 @@
*/
/*
- * $Id: IDAttrNSImpl.cpp,v 1.3 2001/05/16 14:30:21 tng Exp $
+ * $Id: IDAttrNSImpl.cpp,v 1.4 2001/05/23 13:11:36 tng Exp $
*/
#include <util/XMLUniDefs.hpp>
@@ -101,7 +101,7 @@
XMLCh* newName;
XMLCh temp[4000];
if (index >= 3999)
- newName = new XMLCh[XMLString::stringLen(qualifiedName)+1];
+ newName = new (getOwnerDocument()) XMLCh[XMLString::stringLen(qualifiedName)+1];
else
newName = temp;
@@ -110,8 +110,6 @@
this-> fPrefix = ((IDDocumentImpl *)ownerDoc)->getPooledString(newName);
this -> fLocalName = ((IDDocumentImpl *)ownerDoc)->getPooledString(fName+index+1);
- if (index >= 3999)
- delete newName;
}
const XMLCh * URI = xmlnsAlone ?
@@ -187,7 +185,7 @@
int newQualifiedNameLen = prefixLen+1+XMLString::stringLen(fLocalName);
if (newQualifiedNameLen >= 999)
- newName = new XMLCh[newQualifiedNameLen + 1];
+ newName = new (getOwnerDocument()) XMLCh[newQualifiedNameLen + 1];
else
newName = temp;
@@ -199,7 +197,5 @@
fName = ((IDDocumentImpl *)this->getOwnerDocument())->
getPooledString(newName);
- if (newQualifiedNameLen < 1000)
- delete newName;
}
1.3 +5 -1 xml-xerces/c/src/idom/IDDOMImplementation.cpp
Index: IDDOMImplementation.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/idom/IDDOMImplementation.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- IDDOMImplementation.cpp 2001/05/11 13:25:40 1.2
+++ IDDOMImplementation.cpp 2001/05/23 13:11:37 1.3
@@ -56,6 +56,9 @@
/*
* $Log: IDDOMImplementation.cpp,v $
+ * Revision 1.3 2001/05/23 13:11:37 tng
+ * IDOM: Memory fix.
+ *
* Revision 1.2 2001/05/11 13:25:40 tng
* Copyright update.
*
@@ -197,4 +200,5 @@
IDOM_Document *IDDOMImplementation::createDocument()
{
return new IDDocumentImpl();
-}
\ No newline at end of file
+}
+
1.3 +2 -2 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- IDDocumentImpl.cpp 2001/05/11 13:25:41 1.2
+++ IDDocumentImpl.cpp 2001/05/23 13:11:37 1.3
@@ -55,7 +55,7 @@
*/
/*
- * $Id: IDDocumentImpl.cpp,v 1.2 2001/05/11 13:25:41 tng Exp $
+ * $Id: IDDocumentImpl.cpp,v 1.3 2001/05/23 13:11:37 tng Exp $
*/
#include <util/XMLUniDefs.hpp>
@@ -827,7 +827,7 @@
//
// Delegation for functions inherited from IDOM_Node
//
- IDOM_Node *IDDocumentImpl::appendChild(IDOM_Node *newChild) {return fParent.appendChild (newChild); };
+ IDOM_Node *IDDocumentImpl::appendChild(IDOM_Node *newChild) {return insertBefore(newChild, 0); };
IDOM_NamedNodeMap *IDDocumentImpl::getAttributes() const {return fNode.getAttributes (); };
IDOM_NodeList *IDDocumentImpl::getChildNodes() const {return fParent.getChildNodes (); };
IDOM_Node *IDDocumentImpl::getFirstChild() const {return fParent.getFirstChild (); };
1.4 +18 -5 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IDDocumentImpl.hpp 2001/05/17 15:58:41 1.3
+++ IDDocumentImpl.hpp 2001/05/23 13:11:37 1.4
@@ -58,7 +58,7 @@
*/
/*
- * $Id: IDDocumentImpl.hpp,v 1.3 2001/05/17 15:58:41 tng Exp $
+ * $Id: IDDocumentImpl.hpp,v 1.4 2001/05/23 13:11:37 tng Exp $
*/
//
@@ -300,10 +300,23 @@
return p;
}
-// Ignore compiler warning:
-// no matching operator delete found; memory will not be freed if initialization throws an exception
-#pragma warning( push )
-#pragma warning( disable : 4291 )
+inline void * operator new[](size_t amt, IDOM_Document *doc)
+{
+ // idom_revist. Probably should be a checked cast.
+ void *p = ((IDDocumentImpl *)doc)->allocate(amt);
+ return p;
+}
+//define a dummy delete to get rid of matching warning
+inline void operator delete(void* ptr, IDOM_Document *doc)
+{
+ return;
+}
+
+//define the global one
+inline void * operator new[](size_t amt)
+{
+ return ::operator new(amt);
+}
#endif
1.4 +3 -7 xml-xerces/c/src/idom/IDElementNSImpl.cpp
Index: IDElementNSImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/idom/IDElementNSImpl.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IDElementNSImpl.cpp 2001/05/16 14:30:25 1.3
+++ IDElementNSImpl.cpp 2001/05/23 13:11:38 1.4
@@ -55,7 +55,7 @@
*/
/*
- * $Id: IDElementNSImpl.cpp,v 1.3 2001/05/16 14:30:25 tng Exp $
+ * $Id: IDElementNSImpl.cpp,v 1.4 2001/05/23 13:11:38 tng Exp $
*/
#include <util/XMLUniDefs.hpp>
@@ -90,7 +90,7 @@
XMLCh* newName;
XMLCh temp[4000];
if (index >= 3999)
- newName = new XMLCh[XMLString::stringLen(qualifiedName)+1];
+ newName = new (getOwnerDocument()) XMLCh[XMLString::stringLen(qualifiedName)+1];
else
newName = temp;
@@ -99,8 +99,6 @@
this-> fPrefix = ((IDDocumentImpl *)ownerDoc)->getPooledString(newName);
this -> fLocalName = ((IDDocumentImpl *)ownerDoc)->getPooledString(fName+index+1);
- if (index >= 3999)
- delete newName;
}
const XMLCh * URI = IDNodeImpl::mapPrefix(fPrefix, namespaceURI, IDOM_Node::ELEMENT_NODE);
@@ -171,7 +169,7 @@
int newQualifiedNameLen = prefixLen+1+XMLString::stringLen(fLocalName);
if (newQualifiedNameLen >= 999)
- newName = new XMLCh[newQualifiedNameLen + 1];
+ newName = new (getOwnerDocument()) XMLCh[newQualifiedNameLen + 1];
else
newName = temp;
@@ -183,6 +181,4 @@
fName = ((IDDocumentImpl *)this->getOwnerDocument())->
getPooledString(newName);
- if (newQualifiedNameLen < 1000)
- delete newName;
}
1.4 +3 -3 xml-xerces/c/src/idom/IDNodeIDMap.cpp
Index: IDNodeIDMap.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/idom/IDNodeIDMap.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IDNodeIDMap.cpp 2001/05/17 15:58:46 1.3
+++ IDNodeIDMap.cpp 2001/05/23 13:11:38 1.4
@@ -55,7 +55,7 @@
*/
/*
- * $Id: IDNodeIDMap.cpp,v 1.3 2001/05/17 15:58:46 tng Exp $
+ * $Id: IDNodeIDMap.cpp,v 1.4 2001/05/23 13:11:38 tng Exp $
*/
#include "IDAttrImpl.hpp"
@@ -88,7 +88,7 @@
fNumEntries = 0;
fMaxEntries = (unsigned long)(float(fSize) * gMaxFill);
- fTable = new IDOM_Attr *[fSize];
+ fTable = new (fDoc) IDOM_Attr*[fSize];
unsigned int i;
for (i=0; i<fSize; i++)
fTable[i] = 0;
@@ -251,7 +251,7 @@
//
// Allocate the new table.
//
- fTable = new IDOM_Attr *[fSize];
+ fTable = new (fDoc) IDOM_Attr *[fSize];
unsigned int i;
for (i=0; i<fSize; i++)
fTable[i] = 0;
1.4 +5 -2 xml-xerces/c/src/idom/IDNodeVector.cpp
Index: IDNodeVector.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/idom/IDNodeVector.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IDNodeVector.cpp 2001/05/17 15:58:47 1.3
+++ IDNodeVector.cpp 2001/05/23 13:11:39 1.4
@@ -56,6 +56,9 @@
/*
* $Log: IDNodeVector.cpp,v $
+ * Revision 1.4 2001/05/23 13:11:39 tng
+ * IDOM: Memory fix.
+ *
* Revision 1.3 2001/05/17 15:58:47 tng
* IDOM: Add Unix build, and other idom udpates.
*
@@ -92,7 +95,7 @@
void IDNodeVector::init(IDOM_Document *doc, unsigned int size) {
assert(size > 0);
- data = new IDOM_Node *[size];
+ data = new (doc) IDOM_Node *[size];
assert(data != 0);
allocatedSize = size;
nextFreeSlot = 0;
@@ -116,7 +119,7 @@
if (grow < 50) grow = 50;
unsigned int newAllocatedSize = allocatedSize + grow;
IDOM_Document *doc = data[0]->getOwnerDocument();
- IDOM_Node **newData = new IDOM_Node *[newAllocatedSize];
+ IDOM_Node **newData = new (doc) IDOM_Node *[newAllocatedSize];
assert(newData != 0);
for (unsigned int i=0; i<allocatedSize; i++) {
newData[i] = data[i];
1.4 +5 -2 xml-xerces/c/src/idom/IDStringPool.cpp
Index: IDStringPool.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/idom/IDStringPool.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IDStringPool.cpp 2001/05/17 15:58:49 1.3
+++ IDStringPool.cpp 2001/05/23 13:11:39 1.4
@@ -56,6 +56,9 @@
/*
* $Log: IDStringPool.cpp,v $
+ * Revision 1.4 2001/05/23 13:11:39 tng
+ * IDOM: Memory fix.
+ *
* Revision 1.3 2001/05/17 15:58:49 tng
* IDOM: Add Unix build, and other idom udpates.
*
@@ -91,7 +94,7 @@
struct IDStringPoolEntry
{
IDStringPoolEntry *fNext;
- const XMLCh fString[1];
+ XMLCh fString[1];
};
@@ -118,7 +121,7 @@
{
fDoc = doc; // needed to get access to the doc's storage allocator.
fHashTableSize = hashTableSize;
- fHashTable = new IDStringPoolEntry *[hashTableSize];
+ fHashTable = new (fDoc) IDStringPoolEntry *[hashTableSize];
for (int i=0; i<fHashTableSize; i++)
fHashTable[i] = 0;
};
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org