X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b75a7d8f3b4adbae880cab104ce2c6a50eee4db2..48b980fed3435926e0b3a8d72ecb58be703a1c7a:/icuSources/common/ucln_cmn.c diff --git a/icuSources/common/ucln_cmn.c b/icuSources/common/ucln_cmn.c index e74f3015..452e628b 100644 --- a/icuSources/common/ucln_cmn.c +++ b/icuSources/common/ucln_cmn.c @@ -1,7 +1,7 @@ /* ****************************************************************************** * * -* Copyright (C) 2001-2003, International Business Machines * +* Copyright (C) 2001-2006, International Business Machines * * Corporation and others. All Rights Reserved. * * * ****************************************************************************** @@ -16,113 +16,59 @@ #include "unicode/utypes.h" #include "unicode/uclean.h" +#include "utracimp.h" #include "ustr_imp.h" #include "unormimp.h" #include "ucln_cmn.h" #include "umutex.h" #include "ucln.h" +#include "cmemory.h" +#include "uassert.h" -static cleanupFunc *gCleanupFunctions[UCLN_COMMON] = { - NULL, - NULL, - NULL, - NULL, - NULL -}; +static cleanupFunc *gCommonCleanupFunctions[UCLN_COMMON_COUNT]; +static cleanupFunc *gLibCleanupFunctions[UCLN_COMMON]; + +U_CFUNC void +ucln_common_registerCleanup(ECleanupCommonType type, + cleanupFunc *func) +{ + U_ASSERT(UCLN_COMMON_START < type && type < UCLN_COMMON_COUNT); + if (UCLN_COMMON_START < type && type < UCLN_COMMON_COUNT) + { + gCommonCleanupFunctions[type] = func; + } +} U_CAPI void U_EXPORT2 ucln_registerCleanup(ECleanupLibraryType type, cleanupFunc *func) { + U_ASSERT(UCLN_START < type && type < UCLN_COMMON); if (UCLN_START < type && type < UCLN_COMMON) { - gCleanupFunctions[type] = func; + gLibCleanupFunctions[type] = func; } } -/************************************************ - The cleanup order is important in this function. - Please be sure that you have read ucln.h - ************************************************/ -U_CAPI void U_EXPORT2 -u_cleanup(void) -{ - +U_CFUNC UBool ucln_lib_cleanup(void) { ECleanupLibraryType libType = UCLN_START; - while (++libType < UCLN_COMMON) - { - if (gCleanupFunctions[libType]) + ECleanupCommonType commonFunc = UCLN_COMMON_START; + + for (libType++; libType