| OLD | NEW |
| 1 /* | 1 /* |
| 2 ****************************************************************************** | 2 ****************************************************************************** |
| 3 * * | 3 * * |
| 4 * Copyright (C) 2001-2013, International Business Machines * | 4 * Copyright (C) 2001-2014, International Business Machines * |
| 5 * Corporation and others. All Rights Reserved. * | 5 * Corporation and others. All Rights Reserved. * |
| 6 * * | 6 * * |
| 7 ****************************************************************************** | 7 ****************************************************************************** |
| 8 * file name: ucln_io.c | 8 * file name: ucln_io.cpp |
| 9 * encoding: US-ASCII | 9 * encoding: US-ASCII |
| 10 * tab size: 8 (not used) | 10 * tab size: 8 (not used) |
| 11 * indentation:4 | 11 * indentation:4 |
| 12 * | 12 * |
| 13 * created on: 2006August11 | 13 * created on: 2006August11 |
| 14 * created by: George Rhoten | 14 * created by: George Rhoten |
| 15 */ | 15 */ |
| 16 | 16 |
| 17 #include "mutex.h" |
| 17 #include "ucln.h" | 18 #include "ucln.h" |
| 18 #include "ucln_io.h" | 19 #include "ucln_io.h" |
| 19 #include "uassert.h" | 20 #include "uassert.h" |
| 20 | 21 |
| 21 #ifndef U_IO_IMPLEMENTATION | 22 #ifndef U_IO_IMPLEMENTATION |
| 22 #error U_IO_IMPLEMENTATION not set - must be set for all ICU source files in io/
- see http://userguide.icu-project.org/howtouseicu | 23 #error U_IO_IMPLEMENTATION not set - must be set for all ICU source files in io/
- see http://userguide.icu-project.org/howtouseicu |
| 23 #endif | 24 #endif |
| 24 | 25 |
| 25 | 26 |
| 26 /** Auto-client */ | 27 /** Auto-client */ |
| 27 #define UCLN_TYPE UCLN_IO | 28 #define UCLN_TYPE UCLN_IO |
| 28 #include "ucln_imp.h" | 29 #include "ucln_imp.h" |
| 29 | 30 |
| 30 /* Leave this copyright notice here! It needs to go somewhere in this library. *
/ | 31 /* Leave this copyright notice here! It needs to go somewhere in this library. *
/ |
| 31 static const char copyright[] = U_COPYRIGHT_STRING; | 32 static const char copyright[] = U_COPYRIGHT_STRING; |
| 32 | 33 |
| 33 static cleanupFunc *gCleanupFunctions[UCLN_IO_COUNT]; | 34 static cleanupFunc *gCleanupFunctions[UCLN_IO_COUNT]; |
| 34 | 35 |
| 35 static UBool io_cleanup(void) | 36 static UBool io_cleanup(void) |
| 36 { | 37 { |
| 37 ECleanupIOType libType = UCLN_IO_START; | 38 int32_t libType = UCLN_IO_START; |
| 38 | 39 |
| 40 (void)copyright; // Suppress unused variable warning. |
| 39 while (++libType<UCLN_IO_COUNT) { | 41 while (++libType<UCLN_IO_COUNT) { |
| 40 if (gCleanupFunctions[libType]) | 42 if (gCleanupFunctions[libType]) |
| 41 { | 43 { |
| 42 gCleanupFunctions[libType](); | 44 gCleanupFunctions[libType](); |
| 43 gCleanupFunctions[libType] = NULL; | 45 gCleanupFunctions[libType] = NULL; |
| 44 } | 46 } |
| 45 } | 47 } |
| 46 #if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOC
AL)) | 48 #if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOC
AL)) |
| 47 ucln_unRegisterAutomaticCleanup(); | 49 ucln_unRegisterAutomaticCleanup(); |
| 48 #endif | 50 #endif |
| 49 return TRUE; | 51 return TRUE; |
| 50 } | 52 } |
| 51 | 53 |
| 52 void ucln_io_registerCleanup(ECleanupIOType type, | 54 void ucln_io_registerCleanup(ECleanupIOType type, |
| 53 cleanupFunc *func) | 55 cleanupFunc *func) { |
| 54 { | |
| 55 U_ASSERT(UCLN_IO_START < type && type < UCLN_IO_COUNT); | 56 U_ASSERT(UCLN_IO_START < type && type < UCLN_IO_COUNT); |
| 56 ucln_registerCleanup(UCLN_IO, io_cleanup); | |
| 57 if (UCLN_IO_START < type && type < UCLN_IO_COUNT) | |
| 58 { | 57 { |
| 59 gCleanupFunctions[type] = func; | 58 icu::Mutex m; // See ticket 10295 for discussion. |
| 59 ucln_registerCleanup(UCLN_IO, io_cleanup); |
| 60 if (UCLN_IO_START < type && type < UCLN_IO_COUNT) { |
| 61 gCleanupFunctions[type] = func; |
| 62 } |
| 60 } | 63 } |
| 61 | 64 |
| 62 #if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOC
AL)) | 65 #if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOC
AL)) |
| 63 ucln_registerAutomaticCleanup(); | 66 ucln_registerAutomaticCleanup(); |
| 64 #endif | 67 #endif |
| 65 } | 68 } |
| 66 | 69 |
| OLD | NEW |