sl@0: /* sl@0: ****************************************************************************** sl@0: * * sl@0: * Copyright (C) 2001-2004, International Business Machines * sl@0: * Corporation and others. All Rights Reserved. * sl@0: * * sl@0: ****************************************************************************** sl@0: * file name: ucln_cmn.h sl@0: * encoding: US-ASCII sl@0: * tab size: 8 (not used) sl@0: * indentation:4 sl@0: * sl@0: * created on: 2001July05 sl@0: * created by: George Rhoten sl@0: */ sl@0: sl@0: #ifndef __UCLN_H__ sl@0: #define __UCLN_H__ sl@0: sl@0: #include "unicode/utypes.h" sl@0: sl@0: /** These are the functions used to register a library's memory cleanup sl@0: * functions. Each library should define a single library register function sl@0: * to call this API. In the i18n library, it is ucln_i18n_registerCleanup(). sl@0: * sl@0: * None of the cleanup functions should use a mutex to clean up an API's sl@0: * allocated memory because a cleanup function is not meant to be thread safe, sl@0: * and plenty of data cannot be reference counted in order to make sure that sl@0: * no one else needs the allocated data. sl@0: * sl@0: * In order to make a cleanup function get called when u_cleanup is called, sl@0: * You should add your function to the library specific cleanup function. sl@0: * If the cleanup function is not in the common library, the code that sl@0: * allocates the memory should call the library specific cleanup function. sl@0: * For instance, in the i18n library, any memory allocated statically must sl@0: * call ucln_i18n_registerCleanup() from the ucln_in.h header. These library sl@0: * cleanup functions are needed in order to prevent a circular dependency sl@0: * between the common library and any other library. sl@0: * sl@0: * The order of the cleanup is very important. In general, an API that sl@0: * depends on a second API should be cleaned up before the second API. sl@0: * For instance, the default converter in ustring depends upon the converter sl@0: * API. So the default converter should be closed before the converter API sl@0: * has its cache flushed. This will prevent any memory leaks due to sl@0: * reference counting. sl@0: * sl@0: * Please see common/ucln_cmn.{h,c} and i18n/ucln_in.{h,c} for examples. sl@0: */ sl@0: sl@0: typedef enum ECleanupLibraryType { sl@0: UCLN_START = -1, sl@0: UCLN_CUSTOM, /* Custom is for anyone else. */ sl@0: UCLN_LAYOUTEX, sl@0: UCLN_LAYOUT, sl@0: UCLN_IO, sl@0: UCLN_I18N, sl@0: UCLN_COMMON /* This must be the last one to cleanup. */ sl@0: } ECleanupLibraryType; sl@0: sl@0: U_CDECL_BEGIN sl@0: typedef UBool U_CALLCONV cleanupFunc(void); sl@0: U_CDECL_END sl@0: sl@0: U_CAPI void U_EXPORT2 ucln_registerCleanup(ECleanupLibraryType type, sl@0: cleanupFunc *func); sl@0: sl@0: #endif