From 8c1cec35ed2754c6e3d0fb1202cf8306c9b073eb Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Fri, 10 Oct 2003 20:58:22 +0000 Subject: [PATCH] ICU-3259 Fix a memory leak. X-SVN-Rev: 13393 --- icu4c/source/test/cintltst/cintltst.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/icu4c/source/test/cintltst/cintltst.c b/icu4c/source/test/cintltst/cintltst.c index 318d2c7d3cc..0066b22b33b 100644 --- a/icu4c/source/test/cintltst/cintltst.c +++ b/icu4c/source/test/cintltst/cintltst.c @@ -39,7 +39,6 @@ #define CTST_LEAK_CHECK 1 #ifdef CTST_LEAK_CHECK U_CFUNC void ctst_freeAll(void); -U_CFUNC void ctst_init(void); #endif static char* _testDataPath=NULL; @@ -104,7 +103,7 @@ int main(int argc, const char* const argv[]) U_MAIN_INIT_ARGS(argc, argv); - argv2 = (const char**) ctst_malloc(sizeof(char*) * argc); + argv2 = (const char**) malloc(sizeof(char*) * argc); if (argv2 == NULL) { printf("*** Error: Out of memory (too many cmd line args?)\n"); return 1; @@ -150,10 +149,6 @@ int main(int argc, const char* const argv[]) while (REPEAT_TESTS > 0) { /* Loop runs once per complete execution of the tests * used for -r (repeat) test option. */ -#ifdef CTST_LEAK_CHECK - ctst_init(); -#endif - /* Check whether ICU will initialize without forcing the build data directory into * the ICU_DATA path. Success here means either the data dll contains data, or that * this test program was run with ICU_DATA set externally. Failure of this check @@ -244,6 +239,7 @@ int main(int argc, const char* const argv[]) } /* End of loop that repeats the entire test, if requested. (Normally doesn't loop) */ + free((void*)argv2); return nerrors ? 1 : 0; } @@ -623,17 +619,10 @@ U_CFUNC void ctest_resetTimeZone(void) { #define CTST_MAX_ALLOC 10000 /* Array used as a queue */ -static void * ctst_allocated_stuff[CTST_MAX_ALLOC]; +static void * ctst_allocated_stuff[CTST_MAX_ALLOC] = {0}; static int ctst_allocated = 0; static UBool ctst_free = FALSE; -void ctst_init(void) { - int i; - for(i=0; i= CTST_MAX_ALLOC - 1) { ctst_allocated = 0; @@ -651,12 +640,15 @@ void ctst_freeAll() { if(ctst_free == 0) { for(i=0; i