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