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