]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /* |
2 | ****************************************************************************** | |
3 | * * | |
73c04bcf | 4 | * Copyright (C) 2001-2006, International Business Machines * |
b75a7d8f A |
5 | * Corporation and others. All Rights Reserved. * |
6 | * * | |
7 | ****************************************************************************** | |
8 | * file name: ucln_cmn.c | |
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 "unicode/utypes.h" | |
18 | #include "unicode/uclean.h" | |
374ca955 | 19 | #include "utracimp.h" |
b75a7d8f A |
20 | #include "ustr_imp.h" |
21 | #include "unormimp.h" | |
22 | #include "ucln_cmn.h" | |
23 | #include "umutex.h" | |
24 | #include "ucln.h" | |
374ca955 A |
25 | #include "cmemory.h" |
26 | #include "uassert.h" | |
b75a7d8f | 27 | |
374ca955 | 28 | static cleanupFunc *gCommonCleanupFunctions[UCLN_COMMON_COUNT]; |
73c04bcf | 29 | static cleanupFunc *gLibCleanupFunctions[UCLN_COMMON]; |
b75a7d8f | 30 | |
73c04bcf A |
31 | U_CFUNC void |
32 | ucln_common_registerCleanup(ECleanupCommonType type, | |
33 | cleanupFunc *func) | |
b75a7d8f | 34 | { |
374ca955 A |
35 | U_ASSERT(UCLN_COMMON_START < type && type < UCLN_COMMON_COUNT); |
36 | if (UCLN_COMMON_START < type && type < UCLN_COMMON_COUNT) | |
b75a7d8f | 37 | { |
374ca955 | 38 | gCommonCleanupFunctions[type] = func; |
b75a7d8f A |
39 | } |
40 | } | |
41 | ||
73c04bcf A |
42 | U_CAPI void U_EXPORT2 |
43 | ucln_registerCleanup(ECleanupLibraryType type, | |
44 | cleanupFunc *func) | |
45 | { | |
46 | U_ASSERT(UCLN_START < type && type < UCLN_COMMON); | |
47 | if (UCLN_START < type && type < UCLN_COMMON) | |
48 | { | |
49 | gLibCleanupFunctions[type] = func; | |
50 | } | |
51 | } | |
52 | ||
53 | U_CFUNC UBool ucln_lib_cleanup(void) { | |
54 | ECleanupLibraryType libType = UCLN_START; | |
55 | ECleanupCommonType commonFunc = UCLN_COMMON_START; | |
56 | ||
57 | for (libType++; libType<UCLN_COMMON; libType++) { | |
58 | if (gLibCleanupFunctions[libType]) | |
59 | { | |
60 | gLibCleanupFunctions[libType](); | |
61 | gLibCleanupFunctions[libType] = NULL; | |
62 | } | |
63 | } | |
b75a7d8f | 64 | |
73c04bcf | 65 | for (commonFunc++; commonFunc<UCLN_COMMON_COUNT; commonFunc++) { |
374ca955 | 66 | if (gCommonCleanupFunctions[commonFunc]) |
b75a7d8f | 67 | { |
374ca955 A |
68 | gCommonCleanupFunctions[commonFunc](); |
69 | gCommonCleanupFunctions[commonFunc] = NULL; | |
b75a7d8f | 70 | } |
b75a7d8f | 71 | } |
374ca955 | 72 | return TRUE; |
b75a7d8f A |
73 | } |
74 |