bool XMLSynchronizedStringPool::exists(const XMLCh* const newString) const { if(fConstPool->exists(newString)) return true; XMLMutexLock lockInit(&const_cast<XMLSynchronizedStringPool*>(this)->fMutex); return XMLStringPool::exists(newString); }
const XMLCh* XMLSynchronizedStringPool::getValueForId(const unsigned int id) const { if (id <= fConstPool->getStringCount()) return fConstPool->getValueForId(id); unsigned int constCount = fConstPool->getStringCount(); XMLMutexLock lockInit(&const_cast<XMLSynchronizedStringPool*>(this)->fMutex); return XMLStringPool::getValueForId(id-constCount); }
unsigned int XMLSynchronizedStringPool::getId(const XMLCh* const toFind) const { unsigned int retVal = fConstPool->getId(toFind); if(retVal) return retVal; // make sure we return a truly unique id unsigned int constCount = fConstPool->getStringCount(); XMLMutexLock lockInit(&const_cast<XMLSynchronizedStringPool*>(this)->fMutex); return XMLStringPool::getId(toFind)+constCount; }
// --------------------------------------------------------------------------- // XMLSynchronizedStringPool: Pool management methods // --------------------------------------------------------------------------- unsigned int XMLSynchronizedStringPool::addOrFind(const XMLCh* const newString) { unsigned int id = fConstPool->getId(newString); if(id) return id; // might have to add it to our own table. // synchronize this bit unsigned int constCount = fConstPool->getStringCount(); XMLMutexLock lockInit(&fMutex); id = XMLStringPool::addOrFind(newString); return id+constCount; }
static XMLMutex& getErrRprtrMutex() { if (!sErrRprtrMutex) { XMLMutexLock lockInit(XMLPlatformUtils::fgAtomicMutex); if (!sErrRprtrMutex) { sErrRprtrMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager); errRprtrMutexCleanup.registerCleanup(reinitErrRprtrMutex); } } return *sErrRprtrMutex; }
Error hmInit(Address addr) { start = (HmEntry)addr; start->next = (HmEntry)((unsigned long)addr + KERNELHEAPSIZE + sizeof(HmEntryDesc)); start->status = HM_FREED; end = start->next; end->next = NULL; end->status = HM_ALLOCATED; hmLock = &hmLockDesc; lockInit( hmLock); return HM_INITOK; }
// // We need to fault in this mutex. But, since its used for synchronization // itself, we have to do this the low level way using a compare and swap. // static XMLMutex& gMsgMutex() { if (!sScannerMutexRegistered) { XMLMutexLock lockInit(XMLPlatformUtils::fgAtomicMutex); if (!sScannerMutexRegistered) { sMsgMutex = new XMLMutex; msgMutexCleanup.registerCleanup(XMLException::reinitMsgMutex); sScannerMutexRegistered = true; } } return *sMsgMutex; }
// --------------------------------------------------------------------------- // RangeTokenMap: Initialization methods // --------------------------------------------------------------------------- void RangeTokenMap::initializeRegistry() { if (!fRegistryInitialized) { XMLMutexLock lockInit(&fMutex); if (!fRegistryInitialized) { fTokenFactory = new TokenFactory(); fTokenRegistry = new RefHashTableOf<RangeTokenElemMap>(109); fRangeMap = new RefHashTableOf<RangeFactory>(29); fCategories = new XMLStringPool(109); fRegistryInitialized = true; } } }
bool XMLSynchronizedStringPool::exists(const unsigned int id) const { if (!id) return false; // First see if this id belongs to the const pool. // unsigned int constCount = fConstPool->getStringCount(); if (id <= constCount) return true; // The rest needs to be synchronized. // XMLMutexLock lockInit(&const_cast<XMLSynchronizedStringPool*>(this)->fMutex); return id < fCurId + constCount; }
// --------------------------------------------------------------------------- // RangeTokenMap: Getter methods // --------------------------------------------------------------------------- RangeToken* RangeTokenMap::getRange(const XMLCh* const keyword, const bool complement) { if (fTokenRegistry == 0 || fRangeMap == 0 || fCategories == 0) return 0; if (!fTokenRegistry->containsKey(keyword)) return 0; RangeTokenElemMap* elemMap = fTokenRegistry->get(keyword); RangeToken* rangeTok = elemMap->getRangeToken(complement); if (!rangeTok) { XMLMutexLock lockInit(&fMutex); // make sure that it was not created while we were locked rangeTok = elemMap->getRangeToken(complement); if (!rangeTok) { rangeTok = elemMap->getRangeToken(); if (!rangeTok) { unsigned int categId = elemMap->getCategoryId(); const XMLCh* categName = fCategories->getValueForId(categId); RangeFactory* rangeFactory = fRangeMap->get(categName); if (rangeFactory == 0) return 0; rangeFactory->buildRanges(); rangeTok = elemMap->getRangeToken(); } if (complement) { rangeTok = (RangeToken*) RangeToken::complementRanges(rangeTok, fTokenFactory, fTokenRegistry->getMemoryManager()); elemMap->setRangeToken(rangeTok , complement); } } } return rangeTok; }
// --------------------------------------------------------------------------- // TokenFactory - Helper methods // --------------------------------------------------------------------------- void TokenFactory::initializeRegistry() { if (!fRangeInitialized) { XMLMutexLock lockInit(&gTokenFactoryMutex()); if (!fRangeInitialized) { RangeTokenMap::instance()->initializeRegistry(); // Add categories RangeTokenMap::instance()->addCategory(fgXMLCategory); RangeTokenMap::instance()->addCategory(fgASCIICategory); RangeTokenMap::instance()->addCategory(fgUnicodeCategory); RangeTokenMap::instance()->addCategory(fgBlockCategory); // Add xml range factory RangeFactory* rangeFact = new XMLRangeFactory(); RangeTokenMap::instance()->addRangeMap(fgXMLCategory, rangeFact); rangeFact->initializeKeywordMap(); // Add ascii range factory rangeFact = new ASCIIRangeFactory(); RangeTokenMap::instance()->addRangeMap(fgASCIICategory, rangeFact); rangeFact->initializeKeywordMap(); // Add unicode range factory rangeFact = new UnicodeRangeFactory(); RangeTokenMap::instance()->addRangeMap(fgUnicodeCategory, rangeFact); rangeFact->initializeKeywordMap(); // Add block range factory rangeFact = new BlockRangeFactory(); RangeTokenMap::instance()->addRangeMap(fgBlockCategory, rangeFact); rangeFact->initializeKeywordMap(); fRangeInitialized = true; } } }
// // This method is a lazy evaluator for the message loader for exception // messages. // static XMLMsgLoader& gGetMsgLoader() { if (!sMsgLoader) { // Lock the message loader mutex and load the text XMLMutexLock lockInit(&gMsgMutex()); // Fault it in on first request if (!sMsgLoader) { sMsgLoader = XMLPlatformUtils::loadMsgSet(XMLUni::fgExceptDomain); if (!sMsgLoader) XMLPlatformUtils::panic(PanicHandler::Panic_CantLoadMsgDomain); // // Register this XMLMsgLoader for cleanup at Termination. // msgLoaderCleanup.registerCleanup(XMLException::reinitMsgLoader); } } // We got it, so return it return *sMsgLoader; }
/* * Prepares for matching. This method is called just before starting matching */ void RegularExpression::prepare() { XMLMutexLock lockInit(&fMutex); compile(fTokenTree); fMinLength = fTokenTree->getMinLength(); fFirstChar = 0; if (!isSet(fOptions, PROHIBIT_HEAD_CHARACTER_OPTIMIZATION) && !isSet(fOptions, XMLSCHEMA_MODE)) { RangeToken* rangeTok = fTokenFactory->createRange(); int result = fTokenTree->analyzeFirstCharacter(rangeTok, fOptions, fTokenFactory); if (result == Token::FC_TERMINAL) { rangeTok->compactRanges(); fFirstChar = rangeTok; } } if (fOperations != 0 && fOperations->getNextOp() == 0 && (fOperations->getOpType() == Op::O_STRING || fOperations->getOpType() == Op::O_CHAR) ) { fFixedStringOnly = true; if (fOperations->getOpType() == Op::O_STRING) { fMemoryManager->deallocate(fFixedString);//delete [] fFixedString; fFixedString = XMLString::replicate(fOperations->getLiteral(), fMemoryManager); } else{ XMLInt32 ch = fOperations->getData(); if ( ch >= 0x10000) { // add as constant fMemoryManager->deallocate(fFixedString);//delete [] fFixedString; fFixedString = RegxUtil::decomposeToSurrogates(ch, fMemoryManager); } else { XMLCh* dummyStr = (XMLCh*) fMemoryManager->allocate(2 * sizeof(XMLCh));//new XMLCh[2]; dummyStr[0] = (XMLCh) fOperations->getData(); dummyStr[1] = chNull; fMemoryManager->deallocate(fFixedString);//delete [] fFixedString; fFixedString = dummyStr; } } fBMPattern = new (fMemoryManager) BMPattern(fFixedString, 256, isSet(fOptions, IGNORE_CASE), fMemoryManager); } else if (!isSet(fOptions, XMLSCHEMA_MODE) && !isSet(fOptions, PROHIBIT_FIXED_STRING_OPTIMIZATION)) { int fixedOpts = 0; Token* tok = fTokenTree->findFixedString(fOptions, fixedOpts); fMemoryManager->deallocate(fFixedString);//delete [] fFixedString; fFixedString = (tok == 0) ? 0 : XMLString::replicate(tok->getString(), fMemoryManager); if (fFixedString != 0 && XMLString::stringLen(fFixedString) < 2) { fMemoryManager->deallocate(fFixedString);//delete [] fFixedString; fFixedString = 0; } if (fFixedString != 0) { fBMPattern = new (fMemoryManager) BMPattern(fFixedString, 256, isSet(fixedOpts, IGNORE_CASE)); } } }
unsigned int XMLSynchronizedStringPool::getStringCount() const { unsigned int constCount = fConstPool->getStringCount(); XMLMutexLock lockInit(&const_cast<XMLSynchronizedStringPool*>(this)->fMutex); return fCurId+constCount-1; }