mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 15:42:14 +00:00
ICU-2729 Fix a memory leak
X-SVN-Rev: 11625
This commit is contained in:
parent
19c0a21ecb
commit
720401b4b5
5 changed files with 15 additions and 14 deletions
|
@ -42,7 +42,7 @@ static const UChar ACE_PREFIX[] ={ 0x0058,0x004E,0x002d,0x002d } ;
|
|||
|
||||
NamePrepTransform* TestIDNA::prep = NULL;
|
||||
|
||||
static NamePrepTransform* getInstance(UErrorCode& status){
|
||||
NamePrepTransform* TestIDNA::getInstance(UErrorCode& status){
|
||||
if(TestIDNA::prep == NULL){
|
||||
UParseError parseError;
|
||||
TestIDNA::prep = NamePrepTransform::createInstance(parseError, status);
|
||||
|
@ -274,7 +274,7 @@ idnaref_toASCII(const UChar* src, int32_t srcLength,
|
|||
int32_t j=0;
|
||||
// UParseError parseError;
|
||||
// step 2
|
||||
NamePrepTransform* prep = getInstance(*status);
|
||||
NamePrepTransform* prep = TestIDNA::getInstance(*status);
|
||||
|
||||
if(U_FAILURE(*status)){
|
||||
goto CLEANUP;
|
||||
|
@ -414,7 +414,7 @@ idnaref_toUnicode(const UChar* src, int32_t srcLength,
|
|||
reqLength=0;
|
||||
// UParseError parseError;
|
||||
|
||||
NamePrepTransform* prep = getInstance(*status);
|
||||
NamePrepTransform* prep = TestIDNA::getInstance(*status);
|
||||
b1Len = 0;
|
||||
UBool* caseFlags = NULL;
|
||||
|
||||
|
@ -620,7 +620,7 @@ idnaref_IDNToASCII( const UChar* src, int32_t srcLength,
|
|||
int32_t reqLength = 0;
|
||||
// UParseError parseError;
|
||||
|
||||
NamePrepTransform* prep = getInstance(*status);
|
||||
NamePrepTransform* prep = TestIDNA::getInstance(*status);
|
||||
|
||||
//initialize pointers to stack buffers
|
||||
UChar b1Stack[MAX_LABEL_BUFFER_SIZE];
|
||||
|
@ -775,7 +775,7 @@ idnaref_IDNToUnicode( const UChar* src, int32_t srcLength,
|
|||
|
||||
UBool done = FALSE;
|
||||
|
||||
NamePrepTransform* prep = getInstance(*status);
|
||||
NamePrepTransform* prep = TestIDNA::getInstance(*status);
|
||||
|
||||
//initialize pointers to stack buffers
|
||||
UChar b1Stack[MAX_LABEL_BUFFER_SIZE];
|
||||
|
|
|
@ -28,16 +28,12 @@
|
|||
|
||||
const char NamePrepTransform::fgClassID=0;
|
||||
|
||||
NamePrepTransform* NamePrepTransform::transform = NULL;
|
||||
|
||||
//Factory method
|
||||
NamePrepTransform* NamePrepTransform::createInstance(UParseError& parseError, UErrorCode& status){
|
||||
if(transform==NULL){
|
||||
transform = new NamePrepTransform(parseError, status);
|
||||
if(U_FAILURE(status)){
|
||||
delete transform;
|
||||
return NULL;
|
||||
}
|
||||
NamePrepTransform* transform = new NamePrepTransform(parseError, status);
|
||||
if(U_FAILURE(status)){
|
||||
delete transform;
|
||||
return NULL;
|
||||
}
|
||||
return transform;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ private :
|
|||
UnicodeSet prohibited;
|
||||
UnicodeSet labelSeparatorSet;
|
||||
UResourceBundle *bundle;
|
||||
static NamePrepTransform* transform;
|
||||
NamePrepTransform(UParseError& parseError, UErrorCode& status);
|
||||
|
||||
|
||||
|
|
|
@ -1339,6 +1339,9 @@ void TestIDNA::testCompareReferenceImpl(const UChar* src, int32_t srcLen){
|
|||
}
|
||||
void TestIDNA::TestIDNAMonkeyTest(){
|
||||
UnicodeString source;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
getInstance(status); // Init prep
|
||||
|
||||
for(int i=0; i<loopCount; i++){
|
||||
source.truncate(0);
|
||||
|
@ -1356,6 +1359,8 @@ void TestIDNA::TestIDNAMonkeyTest(){
|
|||
source.releaseBuffer();
|
||||
*/
|
||||
|
||||
delete TestIDNA::prep;
|
||||
TestIDNA::prep = NULL;
|
||||
}
|
||||
|
||||
void TestIDNA::TestCompareReferenceImpl(){
|
||||
|
|
|
@ -61,6 +61,7 @@ public:
|
|||
void TestIDNAMonkeyTest();
|
||||
void TestConformance();
|
||||
|
||||
static NamePrepTransform* getInstance(UErrorCode& status);
|
||||
static NamePrepTransform* prep;
|
||||
private:
|
||||
void testToASCII(const char* testName, TestFunc func);
|
||||
|
|
Loading…
Add table
Reference in a new issue