Fixed a memory leak when using the Translate function,

also made change to use the String::toUnicode method instead
of String::toCharArray
This commit is contained in:
kvisco%ziplink.net 2000-03-31 07:10:12 +00:00
parent 9492c6f504
commit 303bee7d02

View File

@ -21,14 +21,14 @@
* Keith Visco, kvisco@ziplink.net
* -- original author.
*
* $Id: StringFunctionCall.cpp,v 1.2 1999/11/15 07:13:13 nisheeth%netscape.com Exp $
* $Id: StringFunctionCall.cpp,v 1.3 2000/03/31 07:10:12 kvisco%ziplink.net Exp $
*/
/**
* StringFunctionCall
* A representation of the XPath String funtions
* @author <A HREF="mailto:kvisco@ziplink.net">Keith Visco</A>
* @version $Revision: 1.2 $ $Date: 1999/11/15 07:13:13 $
* @version $Revision: 1.3 $ $Date: 2000/03/31 07:10:12 $
**/
#include "FunctionLib.h"
@ -200,8 +200,7 @@ ExprResult* StringFunctionCall::evaluate(Node* context, ContextState* cs) {
evaluateToString((Expr*)iter->next(),context, cs, oldChars);
evaluateToString((Expr*)iter->next(),context, cs, newChars);
Int32 size = src.length();
char* chars = new char[size+1];
src.toChar(chars);
UNICODE_CHAR* chars = src.toUnicode(new UNICODE_CHAR[size]);
src.clear();
Int32 newIdx = 0;
Int32 i;
@ -213,6 +212,7 @@ ExprResult* StringFunctionCall::evaluate(Node* context, ContextState* cs) {
}
else src.append(chars[i]);
}
delete chars;
return new StringResult(src);
}
result = new StringResult("");