ucln_in.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #include "ucln.h"
  19. #include "ucln_in.h"
  20. #include "mutex.h"
  21. #include "uassert.h"
  22. /** Auto-client for UCLN_I18N **/
  23. #define UCLN_TYPE UCLN_I18N
  24. #include "ucln_imp.h"
  25. /* Leave this copyright notice here! It needs to go somewhere in this library. */
  26. static const char copyright[] = U_COPYRIGHT_STRING;
  27. static cleanupFunc *gCleanupFunctions[UCLN_I18N_COUNT];
  28. static UBool U_CALLCONV i18n_cleanup()
  29. {
  30. int32_t libType = UCLN_I18N_START;
  31. (void)copyright; /* Suppress unused variable warning with clang. */
  32. while (++libType<UCLN_I18N_COUNT) {
  33. if (gCleanupFunctions[libType])
  34. {
  35. gCleanupFunctions[libType]();
  36. gCleanupFunctions[libType] = nullptr;
  37. }
  38. }
  39. #if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOCAL))
  40. ucln_unRegisterAutomaticCleanup();
  41. #endif
  42. return true;
  43. }
  44. void ucln_i18n_registerCleanup(ECleanupI18NType type,
  45. cleanupFunc *func) {
  46. U_ASSERT(UCLN_I18N_START < type && type < UCLN_I18N_COUNT);
  47. {
  48. icu::Mutex m; // See ticket 10295 for discussion.
  49. ucln_registerCleanup(UCLN_I18N, i18n_cleanup);
  50. if (UCLN_I18N_START < type && type < UCLN_I18N_COUNT) {
  51. gCleanupFunctions[type] = func;
  52. }
  53. }
  54. #if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOCAL))
  55. ucln_registerAutomaticCleanup();
  56. #endif
  57. }