You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ga...@apache.org on 2003/05/12 11:53:55 UTC
cvs commit: xml-xerces/c/src/xercesc/util/regx RegularExpression.cpp
gareth 2003/05/12 02:53:55
Modified: c/src/xercesc/util/regx RegularExpression.cpp
Log:
Memory leak fixes. Patch by Steven White.
Revision Changes Path
1.6 +18 -5 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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- RegularExpression.cpp 18 Dec 2002 13:01:02 -0000 1.5
+++ RegularExpression.cpp 12 May 2003 09:53:54 -0000 1.6
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.6 2003/05/12 09:53:54 gareth
+ * Memory leak fixes. Patch by Steven White.
+ *
* Revision 1.5 2002/12/18 13:01:02 gareth
* New functionality - tokenize and replace. Fixed REVISIT for case insensitive match. Patch by Jennifer Schachter.
*
@@ -701,7 +704,6 @@
lMatch->setNoGroups(fNoGroups);
}
else if (fHasBackReferences) {
-
lMatch = new Match();
lMatch->setNoGroups(fNoGroups);
adoptMatch = true;
@@ -730,6 +732,11 @@
if (subEx){
subEx->addElement(lMatch);
lMatch = new Match(*(context->fMatch));
+
+ //is this correct???
+ if (context->fAdoptMatch)
+ delete context->fMatch;
+
context->fMatch = lMatch;
}
@@ -752,7 +759,9 @@
// tokens, we ignore them and do not add them to the stack.
if (!XMLString::equals(fPattern, &chNull))
tokenStack->addElement(token);
-
+ else
+ delete[] token;
+
} else {
token = new XMLCh[matchStart + 1 - tokStart];
XMLString::subString(token, expression, tokStart, matchStart);
@@ -780,6 +789,8 @@
if (!XMLString::equals(fPattern, &chNull))
tokenStack->addElement(token);
+ else
+ delete[] token;
return tokenStack;
@@ -858,13 +869,15 @@
//if there are subExpressions, then determine the string we want to
//substitute in.
- if (numSubEx != 0)
- curRepString = subInExp(replaceString, matchString, subEx->elementAt(i));
-
+ if (numSubEx != 0) {
+ delete[] (XMLCh*)curRepString;
+ curRepString = subInExp(replaceString, matchString, subEx->elementAt(i));
+ }
result.append(curRepString);
}
}
+ delete[] (XMLCh*)curRepString;
return XMLString::replicate(result.getRawBuffer());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org