/src/icu/source/i18n/ucln_in.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | |
33 | | static UBool U_CALLCONV i18n_cleanup(void) |
34 | 0 | { |
35 | 0 | int32_t libType = UCLN_I18N_START; |
36 | 0 | (void)copyright; /* Suppress unused variable warning with clang. */ |
37 | |
|
38 | 0 | while (++libType<UCLN_I18N_COUNT) { |
39 | 0 | if (gCleanupFunctions[libType]) |
40 | 0 | { |
41 | 0 | gCleanupFunctions[libType](); |
42 | 0 | gCleanupFunctions[libType] = NULL; |
43 | 0 | } |
44 | 0 | } |
45 | | #if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOCAL)) |
46 | | ucln_unRegisterAutomaticCleanup(); |
47 | | #endif |
48 | 0 | return TRUE; |
49 | 0 | } |
50 | | |
51 | | void ucln_i18n_registerCleanup(ECleanupI18NType type, |
52 | 0 | cleanupFunc *func) { |
53 | 0 | U_ASSERT(UCLN_I18N_START < type && type < UCLN_I18N_COUNT); |
54 | 0 | { |
55 | 0 | icu::Mutex m; // See ticket 10295 for discussion. |
56 | 0 | ucln_registerCleanup(UCLN_I18N, i18n_cleanup); |
57 | 0 | if (UCLN_I18N_START < type && type < UCLN_I18N_COUNT) { |
58 | 0 | gCleanupFunctions[type] = func; |
59 | 0 | } |
60 | 0 | } |
61 | | #if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOCAL)) |
62 | | ucln_registerAutomaticCleanup(); |
63 | | #endif |
64 | 0 | } |
65 | | |