diff --git a/icu4c/source/test/cintltst/capitst.c b/icu4c/source/test/cintltst/capitst.c index fd85b51e716..dc0a2e1c133 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 722617ebcdf..93faa88c79b 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 53cd513b587..0f4ef4ffc74 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 150dfaa8482..e4c2d0acca7 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 6ee5e78fa15..23a25c555d5 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 a29a7ce3717..adf9408117a 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 04e9a900305..5bd5bd76f52 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 47846e83ca6..e348776eeaf 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 0b4f45921a8..4ef002fe8fd 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 1aa1fda0b9c..38ea1d193ba 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 93367b357a7..7b2411c09c3 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 681db927ab6..c80d1d50d56 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 6ee690f4970..824c2b56d97 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,