1 /* { dg-do compile } */
2 /* { dg-additional-options "-Wno-return-type" } */
3 /* { dg-skip-if "no pthread_barrier" { *-*-darwin* } } */
6 typedef __SIZE_TYPE__ size_t;
10 } pthread_barrierattr_t;
12 typedef unsigned short XMLCh;
13 typedef unsigned long XMLSize_t;
14 namespace xercesc_2_5 {
18 class DOMDocumentRange {
20 class DOMDocument: public DOMDocumentRange, public DOMNode {
30 public : void* operator new(size_t size, MemoryManager* memMgr);
31 void operator delete(void* p);
32 void operator delete(void* p, MemoryManager* memMgr);
36 NoError = 0 , HshTbl_ZeroModulus = 48 , HshTbl_BadHashFromKey = 49 };
41 namespace xercesc_2_5 {
42 class XMLException : public XMemory {
44 virtual ~XMLException();
45 XMLException(const char* const srcFile, const unsigned int srcLine, MemoryManager* const memoryManager = 0);
46 void loadExceptText ( const XMLExcepts::Codes toLoad );
50 class XMLPlatformUtils {
51 public : static MemoryManager* fgMemoryManager;
52 static inline size_t alignPointerForNewBlockAllocation(size_t ptrSize);
54 inline size_t XMLPlatformUtils::alignPointerForNewBlockAllocation(size_t ptrSize) {
56 class HashBase : public XMemory {
58 virtual bool equals(const void *const key1, const void *const key2) = 0;
62 class IllegalArgumentException : public XMLException {
64 IllegalArgumentException(const char* const srcFile , const unsigned int srcLine , const XMLExcepts::Codes toThrow , MemoryManager* memoryManager = 0) : XMLException(srcFile, srcLine, memoryManager) {
65 loadExceptText(toThrow);
68 class RuntimeException : public XMLException {
70 RuntimeException(const char* const srcFile , const unsigned int srcLine , const XMLExcepts::Codes toThrow , MemoryManager* memoryManager = 0) : XMLException(srcFile, srcLine, memoryManager) {
71 loadExceptText(toThrow);
76 virtual ~MemoryManager() {
78 virtual void* allocate(size_t size) = 0;
80 template <class TElem> class BaseRefVectorOf : public XMemory {
81 BaseRefVectorOf ( const unsigned int maxElems , const bool adoptElems = true , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager );
82 virtual ~BaseRefVectorOf();
86 template <class TElem> BaseRefVectorOf<TElem>::BaseRefVectorOf( const unsigned int maxElems , const bool adoptElems , MemoryManager* const manager) : fAdoptedElems(adoptElems) {
87 for (unsigned int index = 0;
89 index++) fElemList[index] = 0;
91 template <class TElem> BaseRefVectorOf<TElem>::~BaseRefVectorOf() {
95 static bool equals ( const XMLCh* const str1 , const XMLCh* const str2 );
96 static void moveChars ( XMLCh* const targetStr , const XMLCh* const srcStr , const unsigned int count );
98 inline void XMLString::moveChars( XMLCh* const targetStr , const XMLCh* const srcStr , const unsigned int count) {
100 inline bool XMLString::equals( const XMLCh* const str1 , const XMLCh* const str2) {
101 const XMLCh* psz1 = str1;
102 const XMLCh* psz2 = str2;
103 if (psz1 == 0 || psz2 == 0) {
108 namespace xercesc_2_5 {
109 class HashPtr : public HashBase {
110 virtual bool equals(const void *const key1, const void *const key2);
112 template <class TVal> struct DOMDeepNodeListPoolTableBucketElem : public XMemory {
117 template <class TVal> class DOMDeepNodeListPool {
119 DOMDeepNodeListPool ( const XMLSize_t modulus , const bool adoptElems , const XMLSize_t initSize = 128 );
120 TVal* getByKey(const void* const key1, const XMLCh* const key2, const XMLCh* const key3);
121 DOMDeepNodeListPoolTableBucketElem<TVal>* findBucketElem(const void* const key1, const XMLCh* const key2, const XMLCh* const key3, XMLSize_t& hashVal);
123 DOMDeepNodeListPoolTableBucketElem<TVal>** fBucketList;
124 XMLSize_t fHashModulus;
127 XMLSize_t fIdPtrsCount;
128 MemoryManager* fMemoryManager;
130 template <class TVal> DOMDeepNodeListPool<TVal>::DOMDeepNodeListPool( const XMLSize_t modulus , const bool adoptElems , const XMLSize_t initSize) : fAdoptedElems(adoptElems) , fBucketList(0) , fHash(0) , fIdPtrs(0) {
131 fHash = new (fMemoryManager) HashPtr();
132 fIdPtrs = (TVal**) fMemoryManager->allocate(fIdPtrsCount * sizeof(TVal*));
133 if (modulus == 0) throw IllegalArgumentException("./xercesc/dom/impl/bad.c", 38, XMLExcepts::HshTbl_ZeroModulus, fMemoryManager);
135 template <class TVal> TVal* DOMDeepNodeListPool<TVal>::getByKey(const void* const key1, const XMLCh* const key2, const XMLCh* const key3) {
137 DOMDeepNodeListPoolTableBucketElem<TVal>* findIt = findBucketElem(key1, key2, key3, hashVal);
139 template <class TVal> DOMDeepNodeListPoolTableBucketElem<TVal>* DOMDeepNodeListPool<TVal>:: findBucketElem(const void* const key1, const XMLCh* const key2, const XMLCh* const key3, XMLSize_t& hashVal) {
140 if (hashVal > fHashModulus) throw RuntimeException("./xercesc/dom/impl/bad.c", 64, XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager);
141 DOMDeepNodeListPoolTableBucketElem<TVal>* curElem = fBucketList[hashVal];
142 if (fHash->equals(key1, curElem->fKey1) && (XMLString::equals(key2, curElem->fKey2)) && (XMLString::equals(key3, curElem->fKey3))) {
146 class DOMDeepNodeListImpl;
147 class DOMDocumentImpl: public DOMDocument {
148 DOMNodeList* getElementsByTagName(const XMLCh * tagname) const;
149 DOMNodeList* getDeepNodeList(const DOMNode *rootNode, const XMLCh *tagName);
150 DOMNodeList* getDeepNodeList(const DOMNode *rootNode, const XMLCh *namespaceURI, const XMLCh *localName);
151 DOMDeepNodeListPool<DOMDeepNodeListImpl>* fNodeListPool;
154 void * operator new(size_t amt, xercesc_2_5:: DOMDocument *doc);
155 namespace xercesc_2_5 {
158 class DOMDeepNodeListImpl: public DOMNodeList {
160 DOMNodeList *DOMDocumentImpl::getElementsByTagName(const XMLCh *tagname) const {
161 return ((DOMDocumentImpl*)this)->getDeepNodeList(this,tagname);
163 DOMNodeList *DOMDocumentImpl::getDeepNodeList(const DOMNode *rootNode, const XMLCh *tagName) {
165 fNodeListPool = new (this) DOMDeepNodeListPool<DOMDeepNodeListImpl>(109, false);
167 DOMNodeList* retList = fNodeListPool->getByKey(rootNode, tagName, 0);
169 DOMNodeList *DOMDocumentImpl::getDeepNodeList(const DOMNode *rootNode, const XMLCh *namespaceURI, const XMLCh *localName) {
170 DOMNodeList* retList = fNodeListPool->getByKey(rootNode, localName, namespaceURI);