2001-08-11 00:29:58 +00:00
|
|
|
/*
|
|
|
|
******************************************************************************
|
|
|
|
* *
|
2006-03-20 07:35:37 +00:00
|
|
|
* Copyright (C) 2001-2006, International Business Machines *
|
2001-08-11 00:29:58 +00:00
|
|
|
* Corporation and others. All Rights Reserved. *
|
|
|
|
* *
|
|
|
|
******************************************************************************
|
|
|
|
* file name: ucln_cmn.c
|
|
|
|
* encoding: US-ASCII
|
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:4
|
|
|
|
*
|
|
|
|
* created on: 2001July05
|
|
|
|
* created by: George Rhoten
|
|
|
|
*/
|
|
|
|
|
2003-05-06 01:37:52 +00:00
|
|
|
#include "unicode/utypes.h"
|
2001-08-11 00:29:58 +00:00
|
|
|
#include "unicode/uclean.h"
|
2003-10-31 02:19:42 +00:00
|
|
|
#include "utracimp.h"
|
2003-05-06 01:37:52 +00:00
|
|
|
#include "ustr_imp.h"
|
2003-05-02 21:33:17 +00:00
|
|
|
#include "unormimp.h"
|
2001-08-11 00:29:58 +00:00
|
|
|
#include "ucln_cmn.h"
|
|
|
|
#include "umutex.h"
|
2001-08-30 02:59:19 +00:00
|
|
|
#include "ucln.h"
|
2003-08-05 01:25:54 +00:00
|
|
|
#include "cmemory.h"
|
2003-09-25 17:58:08 +00:00
|
|
|
#include "uassert.h"
|
2001-08-30 02:59:19 +00:00
|
|
|
|
2004-10-06 23:10:53 +00:00
|
|
|
static cleanupFunc *gCommonCleanupFunctions[UCLN_COMMON_COUNT];
|
2006-03-31 07:11:33 +00:00
|
|
|
static cleanupFunc *gLibCleanupFunctions[UCLN_COMMON];
|
2003-08-21 20:55:02 +00:00
|
|
|
|
2006-03-31 07:11:33 +00:00
|
|
|
U_CFUNC void
|
|
|
|
ucln_common_registerCleanup(ECleanupCommonType type,
|
|
|
|
cleanupFunc *func)
|
2001-08-30 02:59:19 +00:00
|
|
|
{
|
2004-10-06 23:10:53 +00:00
|
|
|
U_ASSERT(UCLN_COMMON_START < type && type < UCLN_COMMON_COUNT);
|
|
|
|
if (UCLN_COMMON_START < type && type < UCLN_COMMON_COUNT)
|
2001-08-30 02:59:19 +00:00
|
|
|
{
|
2004-10-06 23:10:53 +00:00
|
|
|
gCommonCleanupFunctions[type] = func;
|
2001-08-30 02:59:19 +00:00
|
|
|
}
|
|
|
|
}
|
2001-08-11 00:29:58 +00:00
|
|
|
|
2006-03-31 07:11:33 +00:00
|
|
|
U_CAPI void U_EXPORT2
|
|
|
|
ucln_registerCleanup(ECleanupLibraryType type,
|
|
|
|
cleanupFunc *func)
|
|
|
|
{
|
|
|
|
U_ASSERT(UCLN_START < type && type < UCLN_COMMON);
|
|
|
|
if (UCLN_START < type && type < UCLN_COMMON)
|
|
|
|
{
|
|
|
|
gLibCleanupFunctions[type] = func;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
U_CFUNC UBool ucln_lib_cleanup(void) {
|
|
|
|
ECleanupLibraryType libType = UCLN_START;
|
2006-03-20 07:35:37 +00:00
|
|
|
ECleanupCommonType commonFunc = UCLN_COMMON_START;
|
2004-02-24 00:13:01 +00:00
|
|
|
|
2006-03-31 07:11:33 +00:00
|
|
|
for (libType++; libType<UCLN_COMMON; libType++) {
|
|
|
|
if (gLibCleanupFunctions[libType])
|
|
|
|
{
|
|
|
|
gLibCleanupFunctions[libType]();
|
|
|
|
gLibCleanupFunctions[libType] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-20 07:35:37 +00:00
|
|
|
for (commonFunc++; commonFunc<UCLN_COMMON_COUNT; commonFunc++) {
|
2004-10-06 23:10:53 +00:00
|
|
|
if (gCommonCleanupFunctions[commonFunc])
|
2001-08-30 02:59:19 +00:00
|
|
|
{
|
2004-10-06 23:10:53 +00:00
|
|
|
gCommonCleanupFunctions[commonFunc]();
|
|
|
|
gCommonCleanupFunctions[commonFunc] = NULL;
|
2001-08-30 02:59:19 +00:00
|
|
|
}
|
|
|
|
}
|
2004-10-06 23:10:53 +00:00
|
|
|
return TRUE;
|
2003-04-30 00:09:18 +00:00
|
|
|
}
|
2003-08-05 01:25:54 +00:00
|
|
|
|