1 // © 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 /* 4 ****************************************************************************** 5 * * 6 * Copyright (C) 2001-2014, International Business Machines * 7 * Corporation and others. All Rights Reserved. * 8 * * 9 ****************************************************************************** 10 * file name: ucln_in.cpp 11 * encoding: UTF-8 12 * tab size: 8 (not used) 13 * indentation:4 14 * 15 * created on: 2001July05 16 * created by: George Rhoten 17 */ 18 19 #include "ucln.h" 20 #include "ucln_in.h" 21 #include "mutex.h" 22 #include "uassert.h" 23 24 /** Auto-client for UCLN_I18N **/ 25 #define UCLN_TYPE UCLN_I18N 26 #include "ucln_imp.h" 27 28 /* Leave this copyright notice here! It needs to go somewhere in this library. */ 29 static const char copyright[] = U_COPYRIGHT_STRING; 30 31 static cleanupFunc *gCleanupFunctions[UCLN_I18N_COUNT]; 32 i18n_cleanup(void)33static UBool U_CALLCONV i18n_cleanup(void) 34 { 35 int32_t libType = UCLN_I18N_START; 36 (void)copyright; /* Suppress unused variable warning with clang. */ 37 38 while (++libType<UCLN_I18N_COUNT) { 39 if (gCleanupFunctions[libType]) 40 { 41 gCleanupFunctions[libType](); 42 gCleanupFunctions[libType] = NULL; 43 } 44 } 45 #if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOCAL)) 46 ucln_unRegisterAutomaticCleanup(); 47 #endif 48 return TRUE; 49 } 50 ucln_i18n_registerCleanup(ECleanupI18NType type,cleanupFunc * func)51void ucln_i18n_registerCleanup(ECleanupI18NType type, 52 cleanupFunc *func) { 53 U_ASSERT(UCLN_I18N_START < type && type < UCLN_I18N_COUNT); 54 { 55 icu::Mutex m; // See ticket 10295 for discussion. 56 ucln_registerCleanup(UCLN_I18N, i18n_cleanup); 57 if (UCLN_I18N_START < type && type < UCLN_I18N_COUNT) { 58 gCleanupFunctions[type] = func; 59 } 60 } 61 #if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOCAL)) 62 ucln_registerAutomaticCleanup(); 63 #endif 64 } 65 66