From cc30f756d3efa30e68171bb0ca40d634132f845b Mon Sep 17 00:00:00 2001 From: Vladimir Weinstein Date: Mon, 14 Aug 2000 23:14:23 +0000 Subject: [PATCH] ICU-432 more leaks fixes X-SVN-Rev: 2231 --- icu4c/source/test/cintltst/capitst.c | 3 +++ icu4c/source/test/cintltst/ccurrtst.c | 4 ++++ icu4c/source/test/cintltst/cg7coll.c | 2 ++ icu4c/source/test/cintltst/cintltst.c | 10 ++++++++++ icu4c/source/test/cintltst/citertst.c | 2 ++ icu4c/source/test/cintltst/cstrtest.c | 2 ++ icu4c/source/test/cintltst/mstrmtst.c | 1 + icu4c/source/test/cintltst/ncnvtst.c | 1 - icu4c/source/test/cintltst/udatatst.c | 3 ++- icu4c/source/test/cintltst/utransts.c | 5 ++++- icu4c/source/test/intltest/cpdtrtst.cpp | 2 +- icu4c/source/test/intltest/ittxtbd.cpp | 4 ++++ icu4c/source/test/intltest/jahatrts.cpp | 2 ++ 13 files changed, 37 insertions(+), 4 deletions(-) diff --git a/icu4c/source/test/cintltst/capitst.c b/icu4c/source/test/cintltst/capitst.c index fd85b51e71..dc0a2e1c13 100644 --- a/icu4c/source/test/cintltst/capitst.c +++ b/icu4c/source/test/cintltst/capitst.c @@ -21,6 +21,7 @@ #include "capitst.h" #include "unicode/ustring.h" #include "unicode/ures.h" +#include "cmemory.h" U_CAPI const UChar * U_EXPORT2 ucol_getDefaultRulesArray(uint32_t *size); @@ -94,6 +95,8 @@ void TestGetDefaultRules(){ log_err("Error: ucol_getDefaultRulesArray() failed\n"); } + uprv_free(binColData); + ures_close(binColl); ures_close(res); ucol_close(coll); diff --git a/icu4c/source/test/cintltst/ccurrtst.c b/icu4c/source/test/cintltst/ccurrtst.c index 722617ebcd..93faa88c79 100644 --- a/icu4c/source/test/cintltst/ccurrtst.c +++ b/icu4c/source/test/cintltst/ccurrtst.c @@ -114,8 +114,12 @@ void currTest() reportCResult(source, target, sortKey1, sortKey2, compareResult, keyResult, expectedResult); + free(sortKey1); + free(sortKey2); + } } + ucol_close(c); } diff --git a/icu4c/source/test/cintltst/cg7coll.c b/icu4c/source/test/cintltst/cg7coll.c index 53cd513b58..0f4ef4ffc7 100644 --- a/icu4c/source/test/cintltst/cg7coll.c +++ b/icu4c/source/test/cintltst/cg7coll.c @@ -279,6 +279,7 @@ void TestDemo1() ucol_close(myCollation); ucol_close(col); + free(temp); free(newRules); } void TestDemo2() @@ -322,6 +323,7 @@ void TestDemo2() } ucol_close(myCollation); ucol_close(col); + free(temp); free(newRules); } diff --git a/icu4c/source/test/cintltst/cintltst.c b/icu4c/source/test/cintltst/cintltst.c index 150dfaa848..e4c2d0acca 100644 --- a/icu4c/source/test/cintltst/cintltst.c +++ b/icu4c/source/test/cintltst/cintltst.c @@ -24,6 +24,8 @@ #include "unicode/ucnv.h" #include "unicode/ures.h" +U_CAPI void U_EXPORT2 ucnv_orphanAllConverters(); + static char* _testDirectory=NULL; int main ( int argc, const char **argv ) { @@ -79,6 +81,14 @@ int main ( int argc, const char **argv ) cleanUpDataTable(); ctst_freeAll(); +#if 0 + /* To check for leaks */ + + ucnv_flushCache(); + ucnv_orphanAllConverters(); /* nuke the hashtable.. so that any still-open cnvs are leaked */ + /* above function must be enabled in ucnv_bld.c */ +#endif + return nerrors ? 1 : 0; } diff --git a/icu4c/source/test/cintltst/citertst.c b/icu4c/source/test/cintltst/citertst.c index 6ee5e78fa1..23a25c555d 100644 --- a/icu4c/source/test/cintltst/citertst.c +++ b/icu4c/source/test/cintltst/citertst.c @@ -307,6 +307,8 @@ void backAndForth(UCollationElements *iter) log_verbose("\n"); } + free(orders); + } /** @bug 4108762 diff --git a/icu4c/source/test/cintltst/cstrtest.c b/icu4c/source/test/cintltst/cstrtest.c index a29a7ce371..adf9408117 100644 --- a/icu4c/source/test/cintltst/cstrtest.c +++ b/icu4c/source/test/cintltst/cstrtest.c @@ -16,6 +16,7 @@ #include "cstring.h" #include "cintltst.h" +#include "cmemory.h" static void TestAPI(void); @@ -86,6 +87,7 @@ void TestAPI(void) if(uprv_strcmp(temp, "strdup") !=0 ){ log_err("FAIL: uprv_strdup() failed. Expected: \"strdup\", Got: %s\n", temp); } + uprv_free((char *)temp); uprv_strcpy(src, "this is lower case"); if(T_CString_strnicmp(src, "THIS", 4 ) != 0){ diff --git a/icu4c/source/test/cintltst/mstrmtst.c b/icu4c/source/test/cintltst/mstrmtst.c index 04e9a90030..5bd5bd76f5 100644 --- a/icu4c/source/test/cintltst/mstrmtst.c +++ b/icu4c/source/test/cintltst/mstrmtst.c @@ -49,6 +49,7 @@ void TestMemoryStreamAPI(){ if(memStream == NULL){ log_err("uprv_mstrm_openNew() failed\n"); } + uprv_mstrm_close(memStream); log_verbose("Testing the function uprv_mstrm_openNew() with size=0\n"); memStream=uprv_mstrm_openNew(0); diff --git a/icu4c/source/test/cintltst/ncnvtst.c b/icu4c/source/test/cintltst/ncnvtst.c index 47846e83ca..e348776eea 100644 --- a/icu4c/source/test/cintltst/ncnvtst.c +++ b/icu4c/source/test/cintltst/ncnvtst.c @@ -302,7 +302,6 @@ void TestErrorBehaviour(){ if(!convertFromU(sampleText4MBCS, sizeof(sampleText4MBCS)/sizeof(sampleText4MBCS[0]), expected4MBCS, sizeof(expected4MBCS), "euc-jp", offsets4MBCS, FALSE, U_ZERO_ERROR)) log_err("u-> euc-jp [UCNV_MBCS] \n"); - } diff --git a/icu4c/source/test/cintltst/udatatst.c b/icu4c/source/test/cintltst/udatatst.c index 0b4f45921a..4ef002fe8f 100644 --- a/icu4c/source/test/cintltst/udatatst.c +++ b/icu4c/source/test/cintltst/udatatst.c @@ -558,7 +558,8 @@ void TestErrorConditions(){ } else { log_verbose("calling udat_open with non-existing file returned null as expected\n"); } - + free(path); + free(testPath); } diff --git a/icu4c/source/test/cintltst/utransts.c b/icu4c/source/test/cintltst/utransts.c index 1aa1fda0b9..38ea1d193b 100644 --- a/icu4c/source/test/cintltst/utransts.c +++ b/icu4c/source/test/cintltst/utransts.c @@ -167,6 +167,8 @@ void TestClone(){ utrans_close(t1); utrans_close(t2); + utrans_close(t3); + utrans_close(t4); } @@ -223,7 +225,8 @@ void TestRegisterUnregister(){ return; } - /*utrans_close(rules);*/ + utrans_close(t1); + utrans_close(inverse1); } void TestSimpleRules() { diff --git a/icu4c/source/test/intltest/cpdtrtst.cpp b/icu4c/source/test/intltest/cpdtrtst.cpp index 93367b357a..7b2411c09c 100644 --- a/icu4c/source/test/intltest/cpdtrtst.cpp +++ b/icu4c/source/test/intltest/cpdtrtst.cpp @@ -264,7 +264,7 @@ void CompoundTransliteratorTest::TestGetSetAdoptTransliterator(){ else{ logln("OK: adoptTranslterator() passed"); } -// delete ct1; + delete transarray; } /** diff --git a/icu4c/source/test/intltest/ittxtbd.cpp b/icu4c/source/test/intltest/ittxtbd.cpp index 681db927ab..c80d1d50d5 100644 --- a/icu4c/source/test/intltest/ittxtbd.cpp +++ b/icu4c/source/test/intltest/ittxtbd.cpp @@ -1134,6 +1134,10 @@ void IntlTestTextBoundary::generalIteratorTest(BreakIterator& bi, Vector* expect testIsBoundary(bi, text, boundaries); doMultipleSelectionTest(bi, text); + + delete nextResults; + delete previousResults; + } Vector* IntlTestTextBoundary::testFirstAndNext(BreakIterator& bi, UnicodeString& text) diff --git a/icu4c/source/test/intltest/jahatrts.cpp b/icu4c/source/test/intltest/jahatrts.cpp index 6ee690f497..824c2b56d9 100644 --- a/icu4c/source/test/intltest/jahatrts.cpp +++ b/icu4c/source/test/intltest/jahatrts.cpp @@ -302,6 +302,8 @@ void JamoToHangTransliteratorTest::expectTranslit(const JamoHangulTransliterator equal.handleTransliterate(rsource2, index, TRUE); expectAux(t.getID() + "=OPERATOR:handleTransliterator(increment=TRUE) "+ message, source + "-->" + rsource2, rsource2==expectedResult, expectedResult); + delete clone; + } void JamoToHangTransliteratorTest::expect(const JamoHangulTransliterator& t, const UnicodeString& message,