Jungshik Shin | 87232d8 | 2017-05-13 21:10:13 -0700 | [diff] [blame] | 1 | // © 2016 and later: Unicode, Inc. and others. |
Jungshik Shin | 5feb9ad | 2016-10-21 12:52:48 -0700 | [diff] [blame] | 2 | // License & terms of use: http://www.unicode.org/copyright.html |
Jungshik Shin (jungshik at google) | 0f8746a | 2015-01-08 15:46:45 -0800 | [diff] [blame] | 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 |
Jungshik Shin | 87232d8 | 2017-05-13 21:10:13 -0700 | [diff] [blame] | 11 | * encoding: UTF-8 |
Jungshik Shin (jungshik at google) | 0f8746a | 2015-01-08 15:46:45 -0800 | [diff] [blame] | 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 | |
Jungshik Shin | 5feb9ad | 2016-10-21 12:52:48 -0700 | [diff] [blame] | 33 | static UBool U_CALLCONV i18n_cleanup(void) |
Jungshik Shin (jungshik at google) | 0f8746a | 2015-01-08 15:46:45 -0800 | [diff] [blame] | 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 |
Frank Tang | 1f164ee | 2022-11-08 12:31:27 -0800 | [diff] [blame^] | 48 | return true; |
Jungshik Shin (jungshik at google) | 0f8746a | 2015-01-08 15:46:45 -0800 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | void 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 | |