Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* |
michael@0 | 2 | ****************************************************************************** |
michael@0 | 3 | * |
michael@0 | 4 | * Copyright (C) 2001-2013, International Business Machines |
michael@0 | 5 | * Corporation and others. All Rights Reserved. |
michael@0 | 6 | * |
michael@0 | 7 | ****************************************************************************** |
michael@0 | 8 | * file name: ucln.h |
michael@0 | 9 | * encoding: US-ASCII |
michael@0 | 10 | * tab size: 8 (not used) |
michael@0 | 11 | * indentation:4 |
michael@0 | 12 | * |
michael@0 | 13 | * created on: 2001July05 |
michael@0 | 14 | * created by: George Rhoten |
michael@0 | 15 | */ |
michael@0 | 16 | |
michael@0 | 17 | #ifndef __UCLN_H__ |
michael@0 | 18 | #define __UCLN_H__ |
michael@0 | 19 | |
michael@0 | 20 | #include "unicode/utypes.h" |
michael@0 | 21 | |
michael@0 | 22 | /** These are the functions used to register a library's memory cleanup |
michael@0 | 23 | * functions. Each library should define a single library register function |
michael@0 | 24 | * to call this API. In the i18n library, it is ucln_i18n_registerCleanup(). |
michael@0 | 25 | * |
michael@0 | 26 | * None of the cleanup functions should use a mutex to clean up an API's |
michael@0 | 27 | * allocated memory because a cleanup function is not meant to be thread safe, |
michael@0 | 28 | * and plenty of data cannot be reference counted in order to make sure that |
michael@0 | 29 | * no one else needs the allocated data. |
michael@0 | 30 | * |
michael@0 | 31 | * In order to make a cleanup function get called when u_cleanup is called, |
michael@0 | 32 | * You should add your function to the library specific cleanup function. |
michael@0 | 33 | * If the cleanup function is not in the common library, the code that |
michael@0 | 34 | * allocates the memory should call the library specific cleanup function. |
michael@0 | 35 | * For instance, in the i18n library, any memory allocated statically must |
michael@0 | 36 | * call ucln_i18n_registerCleanup() from the ucln_in.h header. These library |
michael@0 | 37 | * cleanup functions are needed in order to prevent a circular dependency |
michael@0 | 38 | * between the common library and any other library. |
michael@0 | 39 | * |
michael@0 | 40 | * The order of the cleanup is very important. In general, an API that |
michael@0 | 41 | * depends on a second API should be cleaned up before the second API. |
michael@0 | 42 | * For instance, the default converter in ustring depends upon the converter |
michael@0 | 43 | * API. So the default converter should be closed before the converter API |
michael@0 | 44 | * has its cache flushed. This will prevent any memory leaks due to |
michael@0 | 45 | * reference counting. |
michael@0 | 46 | * |
michael@0 | 47 | * Please see common/ucln_cmn.{h,c} and i18n/ucln_in.{h,c} for examples. |
michael@0 | 48 | */ |
michael@0 | 49 | |
michael@0 | 50 | /** |
michael@0 | 51 | * Data Type for cleanup function selector. These roughly correspond to libraries. |
michael@0 | 52 | */ |
michael@0 | 53 | typedef enum ECleanupLibraryType { |
michael@0 | 54 | UCLN_START = -1, |
michael@0 | 55 | UCLN_UPLUG, /* ICU plugins */ |
michael@0 | 56 | UCLN_CUSTOM, /* Custom is for anyone else. */ |
michael@0 | 57 | UCLN_CTESTFW, |
michael@0 | 58 | UCLN_TOOLUTIL, |
michael@0 | 59 | UCLN_LAYOUTEX, |
michael@0 | 60 | UCLN_LAYOUT, |
michael@0 | 61 | UCLN_IO, |
michael@0 | 62 | UCLN_I18N, |
michael@0 | 63 | UCLN_COMMON /* This must be the last one to cleanup. */ |
michael@0 | 64 | } ECleanupLibraryType; |
michael@0 | 65 | |
michael@0 | 66 | /** |
michael@0 | 67 | * Data type for cleanup function pointer |
michael@0 | 68 | */ |
michael@0 | 69 | U_CDECL_BEGIN |
michael@0 | 70 | typedef UBool U_CALLCONV cleanupFunc(void); |
michael@0 | 71 | typedef void U_CALLCONV initFunc(UErrorCode *); |
michael@0 | 72 | U_CDECL_END |
michael@0 | 73 | |
michael@0 | 74 | /** |
michael@0 | 75 | * Register a cleanup function |
michael@0 | 76 | * @param type which library to register for. |
michael@0 | 77 | * @param func the function pointer |
michael@0 | 78 | */ |
michael@0 | 79 | U_CAPI void U_EXPORT2 ucln_registerCleanup(ECleanupLibraryType type, |
michael@0 | 80 | cleanupFunc *func); |
michael@0 | 81 | |
michael@0 | 82 | /** |
michael@0 | 83 | * Request cleanup for one specific library. |
michael@0 | 84 | * Not thread safe. |
michael@0 | 85 | * @param type which library to cleanup |
michael@0 | 86 | */ |
michael@0 | 87 | U_CAPI void U_EXPORT2 ucln_cleanupOne(ECleanupLibraryType type); |
michael@0 | 88 | |
michael@0 | 89 | #endif |