You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2003/05/16 02:03:11 UTC
cvs commit: xml-xerces/c/src/xercesc/util/regx Match.cpp Match.hpp Op.cpp Op.hpp OpFactory.cpp OpFactory.hpp RegularExpression.cpp RegularExpression.hpp RegxParser.cpp RegxUtil.cpp RegxUtil.hpp StringToken.cpp StringToken.hpp TokenFactory.cpp TokenFactory.hpp UnionToken.cpp
knoaman 2003/05/15 17:03:11
Modified: c/src/xercesc/util/regx Match.cpp Match.hpp Op.cpp Op.hpp
OpFactory.cpp OpFactory.hpp RegularExpression.cpp
RegularExpression.hpp RegxParser.cpp RegxUtil.cpp
RegxUtil.hpp StringToken.cpp StringToken.hpp
TokenFactory.cpp TokenFactory.hpp UnionToken.cpp
Log:
Partial implementation of the configurable memory manager.
Revision Changes Path
1.4 +24 -13 xml-xerces/c/src/xercesc/util/regx/Match.cpp
Index: Match.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/regx/Match.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Match.cpp 18 Dec 2002 13:01:02 -0000 1.3
+++ Match.cpp 16 May 2003 00:03:10 -0000 1.4
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.4 2003/05/16 00:03:10 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.3 2002/12/18 13:01:02 gareth
* New functionality - tokenize and replace. Fixed REVISIT for case insensitive match. Patch by Jennifer Schachter.
*
@@ -77,23 +80,30 @@
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/util/regx/Match.hpp>
+#include <xercesc/framework/MemoryManager.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Match: Constructors and Destructors
// ---------------------------------------------------------------------------
-Match::Match() : fNoGroups(0),
- fPositionsSize(0),
- fStartPositions(0),
- fEndPositions(0) {
+Match::Match(MemoryManager* const manager) :
+ fNoGroups(0)
+ , fPositionsSize(0)
+ , fStartPositions(0)
+ , fEndPositions(0)
+ , fMemoryManager(manager)
+{
}
-Match::Match(const Match& toCopy) : fNoGroups(0),
- fPositionsSize(0),
- fStartPositions(0),
- fEndPositions(0){
+Match::Match(const Match& toCopy) :
+ fNoGroups(0)
+ , fPositionsSize(0)
+ , fStartPositions(0)
+ , fEndPositions(0)
+ , fMemoryManager(0)
+{
initialize(toCopy);
}
@@ -118,8 +128,8 @@
cleanUp();
fPositionsSize = n;
- fStartPositions = new int[n];
- fEndPositions = new int[n];
+ fStartPositions = (int*) fMemoryManager->allocate(n * sizeof(int));//new int[n];
+ fEndPositions = (int*) fMemoryManager->allocate(n * sizeof(int));//new int[n];
}
fNoGroups = n;
@@ -138,7 +148,8 @@
//do not copy over value of fPositionSize as it is irrelevant to the
//state of the Match
-
+
+ fMemoryManager = toCopy.fMemoryManager;
int toCopySize = toCopy.getNoGroups();
setNoGroups(toCopySize);
@@ -151,8 +162,8 @@
void Match::cleanUp() {
- delete [] fStartPositions;
- delete [] fEndPositions;
+ fMemoryManager->deallocate(fStartPositions);//delete [] fStartPositions;
+ fMemoryManager->deallocate(fEndPositions);//delete [] fEndPositions;
fStartPositions = 0;
fEndPositions = 0;
1.5 +3 -2 xml-xerces/c/src/xercesc/util/regx/Match.hpp
Index: Match.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/regx/Match.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Match.hpp 15 May 2003 18:42:54 -0000 1.4
+++ Match.hpp 16 May 2003 00:03:10 -0000 1.5
@@ -79,7 +79,7 @@
// -----------------------------------------------------------------------
// Public Constructors and Destructor
// -----------------------------------------------------------------------
- Match();
+ Match(MemoryManager* const manager);
/**
* Copy constructor
@@ -131,6 +131,7 @@
int fPositionsSize;
int* fStartPositions;
int* fEndPositions;
+ MemoryManager* fMemoryManager;
};
/**
1.3 +5 -2 xml-xerces/c/src/xercesc/util/regx/Op.cpp
Index: Op.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/regx/Op.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Op.cpp 4 Nov 2002 15:17:00 -0000 1.2
+++ Op.cpp 16 May 2003 00:03:10 -0000 1.3
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.3 2003/05/16 00:03:10 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.2 2002/11/04 15:17:00 tng
* C++ Namespace Support.
*
@@ -179,9 +182,9 @@
// ---------------------------------------------------------------------------
// UnionOp: Constructors and Destuctors
// ---------------------------------------------------------------------------
-UnionOp::UnionOp(const short type, const int size)
+UnionOp::UnionOp(const short type, const int size, MemoryManager* const manager)
: Op(type)
- , fBranches(new RefVectorOf<Op> (size, false)) {
+ , fBranches(new (manager) RefVectorOf<Op> (size, false)) {
}
1.7 +2 -2 xml-xerces/c/src/xercesc/util/regx/Op.hpp
Index: Op.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/regx/Op.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Op.hpp 15 May 2003 18:42:54 -0000 1.6
+++ Op.hpp 16 May 2003 00:03:10 -0000 1.7
@@ -182,7 +182,7 @@
// -----------------------------------------------------------------------
// Public Constructors and Destructor
// -----------------------------------------------------------------------
- UnionOp(const short type, const int size);
+ UnionOp(const short type, const int size, MemoryManager* const manager);
~UnionOp() { delete fBranches; }
// -----------------------------------------------------------------------
1.5 +6 -3 xml-xerces/c/src/xercesc/util/regx/OpFactory.cpp
Index: OpFactory.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/regx/OpFactory.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- OpFactory.cpp 15 May 2003 18:42:54 -0000 1.4
+++ OpFactory.cpp 16 May 2003 00:03:10 -0000 1.5
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.5 2003/05/16 00:03:10 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.4 2003/05/15 18:42:54 knoaman
* Partial implementation of the configurable memory manager.
*
@@ -91,9 +94,9 @@
// ---------------------------------------------------------------------------
// OpFactory: Constructors and Destructor
// ---------------------------------------------------------------------------
-OpFactory::OpFactory() :
+OpFactory::OpFactory(MemoryManager* const manager) :
fOpVector(0)
- , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
+ , fMemoryManager(manager)
{
fOpVector = new (fMemoryManager) RefVectorOf<Op>(16, true);
}
@@ -141,7 +144,7 @@
UnionOp* OpFactory::createUnionOp(int size) {
- UnionOp* tmpOp = new (fMemoryManager) UnionOp(Op::O_UNION, size);
+ UnionOp* tmpOp = new (fMemoryManager) UnionOp(Op::O_UNION, size, fMemoryManager);
fOpVector->addElement(tmpOp);
return tmpOp;
1.5 +2 -2 xml-xerces/c/src/xercesc/util/regx/OpFactory.hpp
Index: OpFactory.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/regx/OpFactory.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- OpFactory.hpp 15 May 2003 18:42:54 -0000 1.4
+++ OpFactory.hpp 16 May 2003 00:03:10 -0000 1.5
@@ -96,7 +96,7 @@
// -----------------------------------------------------------------------
// Constructors and destructors
// -----------------------------------------------------------------------
- OpFactory();
+ OpFactory(MemoryManager* const manager);
~OpFactory();
// -----------------------------------------------------------------------
1.9 +79 -57 xml-xerces/c/src/xercesc/util/regx/RegularExpression.cpp
Index: RegularExpression.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/regx/RegularExpression.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- RegularExpression.cpp 15 May 2003 18:42:54 -0000 1.8
+++ RegularExpression.cpp 16 May 2003 00:03:10 -0000 1.9
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.9 2003/05/16 00:03:10 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.8 2003/05/15 18:42:54 knoaman
* Partial implementation of the configurable memory manager.
*
@@ -149,7 +152,7 @@
// ---------------------------------------------------------------------------
// RegularExpression::Context: Constructors and Destructor
// ---------------------------------------------------------------------------
-RegularExpression::Context::Context() :
+RegularExpression::Context::Context(MemoryManager* const manager) :
fInUse(false)
, fAdoptMatch(false)
, fStart(0)
@@ -159,13 +162,14 @@
, fOffsets(0)
, fMatch(0)
, fString(0)
+ , fMemoryManager(manager)
{
}
RegularExpression::Context::~Context()
{
- delete [] fOffsets;
- delete [] fString;
+ fMemoryManager->deallocate(fOffsets);//delete [] fOffsets;
+ fMemoryManager->deallocate(fString);//delete [] fString;
if (fAdoptMatch)
delete fMatch;
@@ -178,8 +182,8 @@
, const int start, const int limit
, const int noClosures)
{
- delete [] fString;
- fString = XMLString::replicate(string);
+ fMemoryManager->deallocate(fString);//delete [] fString;
+ fString = XMLString::replicate(string, fMemoryManager);
fStart = start;
fLimit = limit;
fLength = fLimit - fStart;
@@ -190,8 +194,9 @@
if (fOffsets == 0 || fSize != noClosures) {
- delete [] fOffsets;
- fOffsets = new int[noClosures];
+ if (fOffsets)
+ fMemoryManager->deallocate(fOffsets);//delete [] fOffsets;
+ fOffsets = (int*) fMemoryManager->allocate(noClosures * sizeof(int));//new int[noClosures];
}
fSize = noClosures;
@@ -245,12 +250,14 @@
fOperations(0),
fTokenTree(0),
fFirstChar(0),
- fTokenFactory(0)
+ fOpFactory(XMLPlatformUtils::fgMemoryManager),
+ fTokenFactory(0),
+ fMemoryManager(XMLPlatformUtils::fgMemoryManager)
{
try {
- XMLCh* tmpBuf = XMLString::transcode(pattern);
- ArrayJanitor<XMLCh> janBuf(tmpBuf);
+ XMLCh* tmpBuf = XMLString::transcode(pattern, fMemoryManager);
+ ArrayJanitor<XMLCh> janBuf(tmpBuf, fMemoryManager);
setPattern(tmpBuf);
}
catch (...) {
@@ -274,14 +281,17 @@
fFixedString(0),
fOperations(0),
fTokenTree(0),
- fFirstChar(0)
+ fFirstChar(0),
+ fOpFactory(XMLPlatformUtils::fgMemoryManager),
+ fTokenFactory(0),
+ fMemoryManager(XMLPlatformUtils::fgMemoryManager)
{
try {
- XMLCh* tmpBuf = XMLString::transcode(pattern);
- ArrayJanitor<XMLCh> janBuf(tmpBuf);
- XMLCh* tmpOptions = XMLString::transcode(options);
- ArrayJanitor<XMLCh> janOps(tmpOptions);
+ XMLCh* tmpBuf = XMLString::transcode(pattern, fMemoryManager);
+ ArrayJanitor<XMLCh> janBuf(tmpBuf, fMemoryManager);
+ XMLCh* tmpOptions = XMLString::transcode(options, fMemoryManager);
+ ArrayJanitor<XMLCh> janOps(tmpOptions, fMemoryManager);
setPattern(tmpBuf, tmpOptions);
}
catch (...) {
@@ -305,7 +315,10 @@
fFixedString(0),
fOperations(0),
fTokenTree(0),
- fFirstChar(0)
+ fFirstChar(0),
+ fOpFactory(XMLPlatformUtils::fgMemoryManager),
+ fTokenFactory(0),
+ fMemoryManager(XMLPlatformUtils::fgMemoryManager)
{
try {
@@ -332,7 +345,10 @@
fFixedString(0),
fOperations(0),
fTokenTree(0),
- fFirstChar(0)
+ fFirstChar(0),
+ fOpFactory(XMLPlatformUtils::fgMemoryManager),
+ fTokenFactory(0),
+ fMemoryManager(XMLPlatformUtils::fgMemoryManager)
{
try {
@@ -356,12 +372,13 @@
void RegularExpression::setPattern(const XMLCh* const pattern,
const XMLCh* const options) {
- fTokenFactory = new TokenFactory();
+ fTokenFactory = new (fMemoryManager) TokenFactory(fMemoryManager);
fOptions = parseOptions(options);
- fPattern = XMLString::replicate(pattern);
+ fPattern = XMLString::replicate(pattern, fMemoryManager);
RegxParser* regxParser = isSet(fOptions, XMLSCHEMA_MODE)
- ? new ParserForXMLSchema(XMLPlatformUtils::fgMemoryManager) : new RegxParser(XMLPlatformUtils::fgMemoryManager);
+ ? new (fMemoryManager) ParserForXMLSchema(fMemoryManager)
+ : new (fMemoryManager) RegxParser(fMemoryManager);
if (regxParser) {
regxParser->setTokenFactory(fTokenFactory);
@@ -378,32 +395,32 @@
// ---------------------------------------------------------------------------
bool RegularExpression::matches(const char* const expression) {
- XMLCh* tmpBuf = XMLString::transcode(expression);
- ArrayJanitor<XMLCh> janBuf(tmpBuf);
+ XMLCh* tmpBuf = XMLString::transcode(expression, fMemoryManager);
+ ArrayJanitor<XMLCh> janBuf(tmpBuf, fMemoryManager);
return matches(tmpBuf, 0, XMLString::stringLen(tmpBuf), 0);
}
bool RegularExpression::matches(const char* const expression,
const int start, const int end) {
- XMLCh* tmpBuf = XMLString::transcode(expression);
- ArrayJanitor<XMLCh> janBuf(tmpBuf);
+ XMLCh* tmpBuf = XMLString::transcode(expression, fMemoryManager);
+ ArrayJanitor<XMLCh> janBuf(tmpBuf, fMemoryManager);
return matches(tmpBuf, start, end, 0);
}
bool RegularExpression::matches(const char* const expression,
Match* const match) {
- XMLCh* tmpBuf = XMLString::transcode(expression);
- ArrayJanitor<XMLCh> janBuf(tmpBuf);
+ XMLCh* tmpBuf = XMLString::transcode(expression, fMemoryManager);
+ ArrayJanitor<XMLCh> janBuf(tmpBuf, fMemoryManager);
return matches(tmpBuf, 0, XMLString::stringLen(tmpBuf), match);
}
bool RegularExpression::matches(const char* const expression, const int start,
const int end, Match* const pMatch) {
- XMLCh* tmpBuf = XMLString::transcode(expression);
- ArrayJanitor<XMLCh> janBuf(tmpBuf);
+ XMLCh* tmpBuf = XMLString::transcode(expression, fMemoryManager);
+ ArrayJanitor<XMLCh> janBuf(tmpBuf, fMemoryManager);
return matches(tmpBuf, start, end, pMatch);
}
@@ -442,10 +459,10 @@
XMLMutexLock lockInit(&fMutex);
if (fContext == 0)
- fContext = new Context();
+ fContext = new (fMemoryManager) Context(fMemoryManager);
if (fContext->fInUse) {
- context = new Context();
+ context = new (fMemoryManager) Context(fMemoryManager);
tmpContext = context;
}
else {
@@ -465,7 +482,7 @@
}
else if (fHasBackReferences) {
- lMatch = new Match();
+ lMatch = new (fMemoryManager) Match(fMemoryManager);
lMatch->setNoGroups(fNoGroups);
adoptMatch = true;
}
@@ -669,7 +686,7 @@
if (fOperations == 0)
prepare();
- RefArrayVectorOf<XMLCh>* tokenStack = new RefArrayVectorOf<XMLCh>(16, true);
+ RefArrayVectorOf<XMLCh>* tokenStack = new (fMemoryManager) RefArrayVectorOf<XMLCh>(16, true);
Context* context = 0;
Context* tmpContext = 0;
@@ -680,10 +697,10 @@
XMLMutexLock lockInit(&fMutex);
if (fContext == 0)
- fContext = new Context();
+ fContext = new (fMemoryManager) Context(fMemoryManager);
if (fContext->fInUse) {
- context = new Context();
+ context = new (fMemoryManager) Context(fMemoryManager);
tmpContext = context;
}
else {
@@ -699,7 +716,7 @@
bool adoptMatch = false;
if (subEx || fHasBackReferences) {
- lMatch = new Match();
+ lMatch = new (fMemoryManager) Match(fMemoryManager);
adoptMatch = true;
lMatch->setNoGroups(fNoGroups);
}
@@ -726,7 +743,7 @@
if (subEx){
subEx->addElement(lMatch);
- lMatch = new Match(*(context->fMatch));
+ lMatch = new (fMemoryManager) Match(*(context->fMatch));
adoptMatch = true;
context->fAdoptMatch = adoptMatch;
@@ -743,7 +760,7 @@
break;
}
- token = new XMLCh[1];
+ token = (XMLCh*) fMemoryManager->allocate(sizeof(XMLCh));//new XMLCh[1];
token[0] = chNull;
// When you tokenize using zero string, will return each
@@ -753,10 +770,13 @@
if (!XMLString::equals(fPattern, &chNull))
tokenStack->addElement(token);
else
- delete[] token;
+ fMemoryManager->deallocate(token);//delete[] token;
} else {
- token = new XMLCh[matchStart + 1 - tokStart];
+ token = (XMLCh*) fMemoryManager->allocate
+ (
+ (matchStart + 1 - tokStart) * sizeof(XMLCh)
+ );//new XMLCh[matchStart + 1 - tokStart];
XMLString::subString(token, expression, tokStart, matchStart);
tokenStack->addElement(token);
}
@@ -772,18 +792,21 @@
XMLCh* token;
if (matchStart == tokStart + 1){
- token = new XMLCh[1];
+ token = (XMLCh*) fMemoryManager->allocate(sizeof(XMLCh));//new XMLCh[1];
token[0] = chNull;
} else {
- token = new XMLCh[strLength + 1 - tokStart];
+ token = (XMLCh*) fMemoryManager->allocate
+ (
+ (strLength + 1 - tokStart) * sizeof(XMLCh)
+ );//new XMLCh[strLength + 1 - tokStart];
XMLString::subString(token, expression, tokStart, strLength);
}
if (!XMLString::equals(fPattern, &chNull))
tokenStack->addElement(token);
else
- delete[] token;
+ fMemoryManager->deallocate(token);//delete[] token;
return tokenStack;
@@ -836,7 +859,7 @@
ThrowXML(RuntimeException, XMLExcepts::Regex_RepPatMatchesZeroString);
}
- RefVectorOf<Match> *subEx = new RefVectorOf<Match>(10, true);
+ RefVectorOf<Match> *subEx = new (fMemoryManager) RefVectorOf<Match>(10, true);
Janitor<RefVectorOf<Match> > janSubEx(subEx);
//Call to tokenize with Match vector so that we keep track of the locations
@@ -1459,8 +1482,7 @@
XMLBuffer newString;
- XMLCh *indexStr = new XMLCh[2]; //holds the string rep of a
- ArrayJanitor<XMLCh> indexJan(indexStr); //digit
+ XMLCh indexStr[2]; //holds the string rep of a
indexStr[1] = chNull;
int index = -1;
@@ -1550,28 +1572,28 @@
fFixedStringOnly = true;
if (fOperations->getOpType() == Op::O_STRING) {
- delete [] fFixedString;
- fFixedString = XMLString::replicate(fOperations->getLiteral());
+ fMemoryManager->deallocate(fFixedString);//delete [] fFixedString;
+ fFixedString = XMLString::replicate(fOperations->getLiteral(), fMemoryManager);
}
else{
XMLInt32 ch = fOperations->getData();
if ( ch >= 0x10000) { // add as constant
- delete [] fFixedString;
- fFixedString = RegxUtil::decomposeToSurrogates(ch);
+ fMemoryManager->deallocate(fFixedString);//delete [] fFixedString;
+ fFixedString = RegxUtil::decomposeToSurrogates(ch, fMemoryManager);
}
else {
- XMLCh* dummyStr = new XMLCh[2];
+ XMLCh* dummyStr = (XMLCh*) fMemoryManager->allocate(2 * sizeof(XMLCh));//new XMLCh[2];
dummyStr[0] = (XMLCh) fOperations->getData();
dummyStr[1] = chNull;
- delete [] fFixedString;
+ fMemoryManager->deallocate(fFixedString);//delete [] fFixedString;
fFixedString = dummyStr;
}
}
- fBMPattern = new BMPattern(fFixedString, 256,
+ fBMPattern = new (fMemoryManager) BMPattern(fFixedString, 256,
isSet(fOptions, IGNORE_CASE));
}
else if (!isSet(fOptions, XMLSCHEMA_MODE) &&
@@ -1580,20 +1602,20 @@
int fixedOpts = 0;
Token* tok = fTokenTree->findFixedString(fOptions, fixedOpts);
- delete [] fFixedString;
+ fMemoryManager->deallocate(fFixedString);//delete [] fFixedString;
fFixedString = (tok == 0) ? 0
- : XMLString::replicate(tok->getString());
+ : XMLString::replicate(tok->getString(), fMemoryManager);
if (fFixedString != 0 && XMLString::stringLen(fFixedString) < 2) {
- delete [] fFixedString;
+ fMemoryManager->deallocate(fFixedString);//delete [] fFixedString;
fFixedString = 0;
}
if (fFixedString != 0) {
- fBMPattern = new BMPattern(fFixedString, 256,
+ fBMPattern = new (fMemoryManager) BMPattern(fFixedString, 256,
isSet(fixedOpts, IGNORE_CASE));
}
}
1.8 +6 -4 xml-xerces/c/src/xercesc/util/regx/RegularExpression.hpp
Index: RegularExpression.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/regx/RegularExpression.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- RegularExpression.hpp 15 May 2003 18:42:54 -0000 1.7
+++ RegularExpression.hpp 16 May 2003 00:03:10 -0000 1.8
@@ -168,7 +168,7 @@
class XMLUTIL_EXPORT Context : public XMemory
{
public :
- Context();
+ Context(MemoryManager* const manager);
~Context();
inline const XMLCh* getString() const { return fString; }
@@ -185,6 +185,7 @@
int* fOffsets;
Match* fMatch;
XMLCh* fString;
+ MemoryManager* fMemoryManager;
friend class Janitor<Context>;
};
@@ -314,6 +315,7 @@
OpFactory fOpFactory;
XMLMutex fMutex;
TokenFactory* fTokenFactory;
+ MemoryManager* fMemoryManager;
};
@@ -322,8 +324,8 @@
// ---------------------------------------------------------------------------
inline void RegularExpression::cleanUp() {
- delete [] fPattern;
- delete [] fFixedString;
+ fMemoryManager->deallocate(fPattern);//delete [] fPattern;
+ fMemoryManager->deallocate(fFixedString);//delete [] fFixedString;
delete fContext;
delete fBMPattern;
delete fTokenFactory;
1.8 +5 -2 xml-xerces/c/src/xercesc/util/regx/RegxParser.cpp
Index: RegxParser.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/regx/RegxParser.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- RegxParser.cpp 15 May 2003 18:42:55 -0000 1.7
+++ RegxParser.cpp 16 May 2003 00:03:10 -0000 1.8
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.8 2003/05/16 00:03:10 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.7 2003/05/15 18:42:55 knoaman
* Partial implementation of the configurable memory manager.
*
@@ -1054,8 +1057,8 @@
}
else {
- XMLCh* surrogateStr = RegxUtil::decomposeToSurrogates(ch);
- ArrayJanitor<XMLCh> janSurrogate(surrogateStr);
+ XMLCh* surrogateStr = RegxUtil::decomposeToSurrogates(ch, fMemoryManager);
+ ArrayJanitor<XMLCh> janSurrogate(surrogateStr, fMemoryManager);
tok = fTokenFactory->createString(surrogateStr);
}
}
1.4 +6 -2 xml-xerces/c/src/xercesc/util/regx/RegxUtil.cpp
Index: RegxUtil.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/regx/RegxUtil.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RegxUtil.cpp 15 May 2003 18:42:55 -0000 1.3
+++ RegxUtil.cpp 16 May 2003 00:03:10 -0000 1.4
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.4 2003/05/16 00:03:10 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.3 2003/05/15 18:42:55 knoaman
* Partial implementation of the configurable memory manager.
*
@@ -84,9 +87,10 @@
XERCES_CPP_NAMESPACE_BEGIN
-XMLCh* RegxUtil::decomposeToSurrogates(XMLInt32 ch) {
+XMLCh* RegxUtil::decomposeToSurrogates(XMLInt32 ch,
+ MemoryManager* const manager) {
- XMLCh* pszStr = new XMLCh[3];
+ XMLCh* pszStr = (XMLCh*) manager->allocate(3 * sizeof(XMLCh));//new XMLCh[3];
ch -= 0x10000;
pszStr[0] = XMLCh((ch >> 10) + 0xD800);
1.4 +3 -2 xml-xerces/c/src/xercesc/util/regx/RegxUtil.hpp
Index: RegxUtil.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/regx/RegxUtil.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RegxUtil.hpp 15 May 2003 18:42:55 -0000 1.3
+++ RegxUtil.hpp 16 May 2003 00:03:10 -0000 1.4
@@ -84,7 +84,8 @@
static bool isWordChar(const XMLCh);
static bool isLowSurrogate(const XMLCh ch);
static bool isHighSurrogate(const XMLCh ch);
- static XMLCh* decomposeToSurrogates(XMLInt32 ch);
+ static XMLCh* decomposeToSurrogates(XMLInt32 ch,
+ MemoryManager* const manager);
static XMLCh* stripExtendedComment(const XMLCh* const expression,
MemoryManager* const manager = 0);
1.3 +8 -3 xml-xerces/c/src/xercesc/util/regx/StringToken.cpp
Index: StringToken.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/regx/StringToken.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- StringToken.cpp 4 Nov 2002 15:17:00 -0000 1.2
+++ StringToken.cpp 16 May 2003 00:03:10 -0000 1.3
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.3 2003/05/16 00:03:10 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.2 2002/11/04 15:17:00 tng
* C++ Namespace Support.
*
@@ -82,10 +85,12 @@
// ---------------------------------------------------------------------------
StringToken::StringToken(const unsigned short tokType,
const XMLCh* const literal,
- const int refNo)
+ const int refNo,
+ MemoryManager* const manager)
: Token(tokType)
- , fString(XMLString::replicate(literal))
+ , fString(XMLString::replicate(literal, manager))
, fRefNo(refNo)
+ , fMemoryManager(manager)
{
}
@@ -93,7 +98,7 @@
StringToken::~StringToken() {
- delete [] fString;
+ fMemoryManager->deallocate(fString);//delete [] fString;
}
XERCES_CPP_NAMESPACE_END
1.4 +3 -2 xml-xerces/c/src/xercesc/util/regx/StringToken.hpp
Index: StringToken.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/regx/StringToken.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StringToken.hpp 7 Mar 2003 18:13:58 -0000 1.3
+++ StringToken.hpp 16 May 2003 00:03:10 -0000 1.4
@@ -75,7 +75,7 @@
// Public Constructors and Destructor
// -----------------------------------------------------------------------
StringToken(const unsigned short tokType, const XMLCh* const literal,
- const int refNo);
+ const int refNo, MemoryManager* const manager);
~StringToken();
// -----------------------------------------------------------------------
@@ -101,6 +101,7 @@
// -----------------------------------------------------------------------
int fRefNo;
XMLCh* fString;
+ MemoryManager* fMemoryManager;
};
1.6 +22 -18 xml-xerces/c/src/xercesc/util/regx/TokenFactory.cpp
Index: TokenFactory.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/regx/TokenFactory.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TokenFactory.cpp 4 Mar 2003 21:11:12 -0000 1.5
+++ TokenFactory.cpp 16 May 2003 00:03:10 -0000 1.6
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.6 2003/05/16 00:03:10 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.5 2003/03/04 21:11:12 knoaman
* [Bug 17516] Thread safety problems in ../util/ and ../util/regx.
*
@@ -119,8 +122,8 @@
// ---------------------------------------------------------------------------
// TokenFactory: Constructors and Destructor
// ---------------------------------------------------------------------------
-TokenFactory::TokenFactory() :
- fTokens(new RefVectorOf<Token> (16, true))
+TokenFactory::TokenFactory(MemoryManager* const manager) :
+ fTokens(new (manager) RefVectorOf<Token> (16, true))
, fEmpty(0)
, fLineBegin(0)
, fLineBegin2(0)
@@ -135,6 +138,7 @@
, fDot(0)
, fCombiningChar(0)
, fGrapheme(0)
+ , fMemoryManager(manager)
{
}
@@ -153,7 +157,7 @@
if (tokType == Token::T_EMPTY && fEmpty != 0)
return fEmpty;
- Token* tmpTok = new Token(tokType);
+ Token* tmpTok = new (fMemoryManager) Token(tokType);
if (tokType == Token::T_EMPTY) {
fEmpty = tmpTok;
@@ -168,7 +172,7 @@
ParenToken* TokenFactory::createLook(const unsigned short tokType,
Token* const token) {
- ParenToken* tmpTok = new ParenToken(tokType, token, 0);
+ ParenToken* tmpTok = new (fMemoryManager) ParenToken(tokType, token, 0);
fTokens->addElement(tmpTok);
return tmpTok;
@@ -177,7 +181,7 @@
ParenToken* TokenFactory::createParenthesis(Token* const token,
const int noGroups) {
- ParenToken* tmpTok = new ParenToken(Token::T_PAREN, token, noGroups);
+ ParenToken* tmpTok = new (fMemoryManager) ParenToken(Token::T_PAREN, token, noGroups);
fTokens->addElement(tmpTok);
return tmpTok;
@@ -186,8 +190,8 @@
ClosureToken* TokenFactory::createClosure(Token* const token,
bool isNonGreedy) {
- ClosureToken* tmpTok = isNonGreedy ? new ClosureToken(Token::T_NONGREEDYCLOSURE, token)
- : new ClosureToken(Token::T_CLOSURE, token);
+ ClosureToken* tmpTok = isNonGreedy ? new (fMemoryManager) ClosureToken(Token::T_NONGREEDYCLOSURE, token)
+ : new (fMemoryManager) ClosureToken(Token::T_CLOSURE, token);
fTokens->addElement(tmpTok);
return tmpTok;
@@ -196,7 +200,7 @@
ConcatToken* TokenFactory::createConcat(Token* const token1,
Token* const token2) {
- ConcatToken* tmpTok = new ConcatToken(token1, token2);
+ ConcatToken* tmpTok = new (fMemoryManager) ConcatToken(token1, token2);
fTokens->addElement(tmpTok);
return tmpTok;
@@ -204,8 +208,8 @@
UnionToken* TokenFactory::createUnion(const bool isConcat) {
- UnionToken* tmpTok = isConcat ? new UnionToken(Token::T_CONCAT)
- : new UnionToken(Token::T_UNION);
+ UnionToken* tmpTok = isConcat ? new (fMemoryManager) UnionToken(Token::T_CONCAT)
+ : new (fMemoryManager) UnionToken(Token::T_UNION);
fTokens->addElement(tmpTok);
return tmpTok;
@@ -214,8 +218,8 @@
RangeToken* TokenFactory::createRange(const bool isNegRange){
- RangeToken* tmpTok = isNegRange ? new RangeToken(Token::T_NRANGE)
- : new RangeToken(Token::T_RANGE);
+ RangeToken* tmpTok = isNegRange ? new (fMemoryManager) RangeToken(Token::T_NRANGE)
+ : new (fMemoryManager) RangeToken(Token::T_RANGE);
fTokens->addElement(tmpTok);
return tmpTok;
@@ -225,8 +229,8 @@
CharToken* TokenFactory::createChar(const XMLUInt32 ch, const bool isAnchor) {
- CharToken* tmpTok = isAnchor ? new CharToken(Token::T_ANCHOR, ch)
- : new CharToken(Token::T_CHAR, ch);
+ CharToken* tmpTok = isAnchor ? new (fMemoryManager) CharToken(Token::T_ANCHOR, ch)
+ : new (fMemoryManager) CharToken(Token::T_CHAR, ch);
fTokens->addElement(tmpTok);
return tmpTok;
@@ -234,7 +238,7 @@
StringToken* TokenFactory::createBackReference(const int noRefs) {
- StringToken* tmpTok = new StringToken(Token::T_BACKREFERENCE, 0, noRefs);
+ StringToken* tmpTok = new (fMemoryManager) StringToken(Token::T_BACKREFERENCE, 0, noRefs, fMemoryManager);
fTokens->addElement(tmpTok);
return tmpTok;
@@ -242,7 +246,7 @@
StringToken* TokenFactory::createString(const XMLCh* const literal) {
- StringToken* tmpTok = new StringToken(Token::T_STRING, literal, 0);
+ StringToken* tmpTok = new (fMemoryManager) StringToken(Token::T_STRING, literal, 0, fMemoryManager);
fTokens->addElement(tmpTok);
return tmpTok;
@@ -252,7 +256,7 @@
const int add,
const int mask) {
- ModifierToken* tmpTok = new ModifierToken(child, add, mask);
+ ModifierToken* tmpTok = new (fMemoryManager) ModifierToken(child, add, mask);
fTokens->addElement(tmpTok);
return tmpTok;
@@ -263,7 +267,7 @@
Token* const yesFlow,
Token* const noFlow) {
- ConditionToken* tmpTok = new ConditionToken(refNo, condition, yesFlow,
+ ConditionToken* tmpTok = new (fMemoryManager) ConditionToken(refNo, condition, yesFlow,
noFlow);
fTokens->addElement(tmpTok);
return tmpTok;
1.6 +3 -2 xml-xerces/c/src/xercesc/util/regx/TokenFactory.hpp
Index: TokenFactory.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/regx/TokenFactory.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TokenFactory.hpp 15 May 2003 18:42:55 -0000 1.5
+++ TokenFactory.hpp 16 May 2003 00:03:10 -0000 1.6
@@ -90,7 +90,7 @@
// -----------------------------------------------------------------------
// Constructors and destructors
// -----------------------------------------------------------------------
- TokenFactory();
+ TokenFactory(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~TokenFactory();
// -----------------------------------------------------------------------
@@ -181,6 +181,7 @@
Token* fDot;
Token* fCombiningChar;
Token* fGrapheme;
+ MemoryManager* fMemoryManager;
};
XERCES_CPP_NAMESPACE_END
1.4 +7 -4 xml-xerces/c/src/xercesc/util/regx/UnionToken.cpp
Index: UnionToken.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/regx/UnionToken.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- UnionToken.cpp 4 Nov 2002 15:17:01 -0000 1.3
+++ UnionToken.cpp 16 May 2003 00:03:10 -0000 1.4
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.4 2003/05/16 00:03:10 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.3 2002/11/04 15:17:01 tng
* C++ Namespace Support.
*
@@ -179,9 +182,9 @@
if (ch >= 0x10000) {
- XMLCh* chSurrogate = RegxUtil::decomposeToSurrogates(ch);
+ XMLCh* chSurrogate = RegxUtil::decomposeToSurrogates(ch, XMLPlatformUtils::fgMemoryManager);
stringBuf.append(chSurrogate);
- delete [] chSurrogate;
+ XMLPlatformUtils::fgMemoryManager->deallocate(chSurrogate);//delete [] chSurrogate;
}
else {
stringBuf.append((XMLCh) ch);
@@ -200,9 +203,9 @@
if (ch >= 0x10000) {
- XMLCh* chSurrogate = RegxUtil::decomposeToSurrogates(ch);
+ XMLCh* chSurrogate = RegxUtil::decomposeToSurrogates(ch, XMLPlatformUtils::fgMemoryManager);
stringBuf.append(chSurrogate);
- delete [] chSurrogate;
+ XMLPlatformUtils::fgMemoryManager->deallocate(chSurrogate);//delete [] chSurrogate;
}
else {
stringBuf.append((XMLCh) ch);
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org