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

@ -3,32 +3,32 @@
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
*
* The Original Code is TransforMiiX XSLT processor.
*
*
* The Initial Developer of the Original Code is The MITRE Corporation.
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
*
* Portions created by Keith Visco as a Non MITRE employee,
* (C) 1999 Keith Visco. All Rights Reserved.
*
* Contributor(s):
*
* Contributor(s):
* 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("");