1 /* 2 ****************************************************************************** 3 * * 4 * Copyright (C) 2001-2006, International Business Machines * 5 * Corporation and others. All Rights Reserved. * 6 * * 7 ****************************************************************************** 8 * file name: ucln_cmn.c 9 * encoding: US-ASCII 10 * tab size: 8 (not used) 11 * indentation:4 12 * 13 * created on: 2001July05 14 * created by: George Rhoten 15 */ 16 17 #include "unicode/utypes.h" 18 #include "unicode/uclean.h" 19 #include "utracimp.h" 20 #include "ustr_imp.h" 21 #include "unormimp.h" 22 #include "ucln_cmn.h" 23 #include "umutex.h" 24 #include "ucln.h" 25 #include "cmemory.h" 26 #include "uassert.h" 27 28 static cleanupFunc *gCommonCleanupFunctions[UCLN_COMMON_COUNT]; 29 static cleanupFunc *gLibCleanupFunctions[UCLN_COMMON]; 30 31 U_CFUNC void ucln_common_registerCleanup(ECleanupCommonType type,cleanupFunc * func)32ucln_common_registerCleanup(ECleanupCommonType type, 33 cleanupFunc *func) 34 { 35 U_ASSERT(UCLN_COMMON_START < type && type < UCLN_COMMON_COUNT); 36 if (UCLN_COMMON_START < type && type < UCLN_COMMON_COUNT) 37 { 38 gCommonCleanupFunctions[type] = func; 39 } 40 } 41 42 U_CAPI void U_EXPORT2 ucln_registerCleanup(ECleanupLibraryType type,cleanupFunc * func)43ucln_registerCleanup(ECleanupLibraryType type, 44 cleanupFunc *func) 45 { 46 U_ASSERT(UCLN_START < type && type < UCLN_COMMON); 47 if (UCLN_START < type && type < UCLN_COMMON) 48 { 49 gLibCleanupFunctions[type] = func; 50 } 51 } 52 ucln_lib_cleanup(void)53U_CFUNC UBool ucln_lib_cleanup(void) { 54 ECleanupLibraryType libType = UCLN_START; 55 ECleanupCommonType commonFunc = UCLN_COMMON_START; 56 57 for (libType++; libType<UCLN_COMMON; libType++) { 58 if (gLibCleanupFunctions[libType]) 59 { 60 gLibCleanupFunctions[libType](); 61 gLibCleanupFunctions[libType] = NULL; 62 } 63 } 64 65 for (commonFunc++; commonFunc<UCLN_COMMON_COUNT; commonFunc++) { 66 if (gCommonCleanupFunctions[commonFunc]) 67 { 68 gCommonCleanupFunctions[commonFunc](); 69 gCommonCleanupFunctions[commonFunc] = NULL; 70 } 71 } 72 return TRUE; 73 } 74 75