]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
b75a7d8f A |
3 | /* |
4 | ****************************************************************************** | |
5 | * * | |
57a6839d | 6 | * Copyright (C) 2001-2014, International Business Machines * |
b75a7d8f A |
7 | * Corporation and others. All Rights Reserved. * |
8 | * * | |
9 | ****************************************************************************** | |
b331163b | 10 | * file name: ucln_in.cpp |
f3c0d7a5 | 11 | * encoding: UTF-8 |
b75a7d8f A |
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" | |
b331163b | 21 | #include "mutex.h" |
374ca955 | 22 | #include "uassert.h" |
b75a7d8f | 23 | |
729e4ab9 A |
24 | /** Auto-client for UCLN_I18N **/ |
25 | #define UCLN_TYPE UCLN_I18N | |
26 | #include "ucln_imp.h" | |
27 | ||
b75a7d8f A |
28 | /* Leave this copyright notice here! It needs to go somewhere in this library. */ |
29 | static const char copyright[] = U_COPYRIGHT_STRING; | |
30 | ||
374ca955 A |
31 | static cleanupFunc *gCleanupFunctions[UCLN_I18N_COUNT]; |
32 | ||
f3c0d7a5 | 33 | static UBool U_CALLCONV i18n_cleanup(void) |
b75a7d8f | 34 | { |
b331163b | 35 | int32_t libType = UCLN_I18N_START; |
57a6839d | 36 | (void)copyright; /* Suppress unused variable warning with clang. */ |
374ca955 | 37 | |
73c04bcf | 38 | while (++libType<UCLN_I18N_COUNT) { |
374ca955 A |
39 | if (gCleanupFunctions[libType]) |
40 | { | |
41 | gCleanupFunctions[libType](); | |
42 | gCleanupFunctions[libType] = NULL; | |
43 | } | |
44 | } | |
729e4ab9 A |
45 | #if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOCAL)) |
46 | ucln_unRegisterAutomaticCleanup(); | |
47 | #endif | |
b75a7d8f A |
48 | return TRUE; |
49 | } | |
50 | ||
374ca955 | 51 | void ucln_i18n_registerCleanup(ECleanupI18NType type, |
b331163b | 52 | cleanupFunc *func) { |
374ca955 | 53 | U_ASSERT(UCLN_I18N_START < type && type < UCLN_I18N_COUNT); |
374ca955 | 54 | { |
b331163b A |
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 | } | |
374ca955 | 60 | } |
729e4ab9 A |
61 | #if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOCAL)) |
62 | ucln_registerAutomaticCleanup(); | |
63 | #endif | |
b75a7d8f A |
64 | } |
65 |