ICU-2729 Fix a memory leak

X-SVN-Rev: 11620
This commit is contained in:
George Rhoten 2003-04-22 15:49:53 +00:00
parent 7add969d05
commit b69c8dcb62
4 changed files with 13 additions and 7 deletions

View file

@ -20,7 +20,7 @@
#include "cmemory.h"
#include "sprpimpl.h"
#include "nptrans.h"
//#include "punyref.h"
#include "testidna.h"
#include "punycode.h"
#include "unicode/ustring.h"
@ -40,18 +40,18 @@ static const UChar ACE_PREFIX[] ={ 0x0058,0x004E,0x002d,0x002d } ;
#define FULL_STOP 0x002E
static NamePrepTransform* prep = NULL;
NamePrepTransform* TestIDNA::prep = NULL;
static NamePrepTransform* getInstance(UErrorCode& status){
if(prep == NULL){
if(TestIDNA::prep == NULL){
UParseError parseError;
prep = NamePrepTransform::createInstance(parseError, status);
if(prep ==NULL){
TestIDNA::prep = NamePrepTransform::createInstance(parseError, status);
if(TestIDNA::prep ==NULL){
status = U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
}
return prep;
return TestIDNA::prep;
}

View file

@ -64,7 +64,7 @@ NamePrepTransform::NamePrepTransform(UParseError& parseError, UErrorCode& status
const UChar* ruleUChar = ures_getStringByKey(bundle, "MapNFKC",&ruleLen, &status);
UnicodeString rule(ruleUChar, ruleLen);
mapping = Transliterator::createFromRules("NamePrepTransform", rule,
mapping = Transliterator::createFromRules(UnicodeString("NamePrepTransform", ""), rule,
UTRANS_FORWARD, parseError,status);
//create the unassigned set

View file

@ -25,6 +25,7 @@
#include "cmemory.h"
#include "testidna.h"
#include "idnaref.h"
#include "nptrans.h"
static UChar unicodeIn[][41] ={
{
@ -1394,6 +1395,8 @@ void TestIDNA::TestRefIDNA(){
"idnaref_IDNToUnicode",idnaref_IDNToUnicode
);
testChaining("idnaref_toASCII",idnaref_toASCII, "idnaref_toUnicode", idnaref_toUnicode);
delete TestIDNA::prep;
TestIDNA::prep = NULL;
}
void TestIDNA::TestDataFile(){

View file

@ -38,6 +38,7 @@ U_CDECL_END
// test the API
class NamePrepTransform;
/**
* @test
@ -60,6 +61,7 @@ public:
void TestIDNAMonkeyTest();
void TestConformance();
static NamePrepTransform* prep;
private:
void testToASCII(const char* testName, TestFunc func);
void testToUnicode(const char* testName, TestFunc func);
@ -97,6 +99,7 @@ private:
const char* IDNToUnicodeName, TestFunc IDNToUnicode,
const char* toUnicodeName, TestFunc toUnicode
);
};
// test the TRIE data structure