os/textandloc/fontservices/textshaperplugin/IcuSource/common/ucln.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/common/ucln.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,67 @@
     1.4 +/*
     1.5 +******************************************************************************
     1.6 +*                                                                            *
     1.7 +* Copyright (C) 2001-2004, International Business Machines                   *
     1.8 +*                Corporation and others. All Rights Reserved.                *
     1.9 +*                                                                            *
    1.10 +******************************************************************************
    1.11 +*   file name:  ucln_cmn.h
    1.12 +*   encoding:   US-ASCII
    1.13 +*   tab size:   8 (not used)
    1.14 +*   indentation:4
    1.15 +*
    1.16 +*   created on: 2001July05
    1.17 +*   created by: George Rhoten
    1.18 +*/
    1.19 +
    1.20 +#ifndef __UCLN_H__
    1.21 +#define __UCLN_H__
    1.22 +
    1.23 +#include "unicode/utypes.h"
    1.24 +
    1.25 +/** These are the functions used to register a library's memory cleanup
    1.26 + * functions.  Each library should define a single library register function
    1.27 + * to call this API.  In the i18n library, it is ucln_i18n_registerCleanup().
    1.28 + *
    1.29 + * None of the cleanup functions should use a mutex to clean up an API's
    1.30 + * allocated memory because a cleanup function is not meant to be thread safe,
    1.31 + * and plenty of data cannot be reference counted in order to make sure that
    1.32 + * no one else needs the allocated data.
    1.33 + *
    1.34 + * In order to make a cleanup function get called when u_cleanup is called,
    1.35 + * You should add your function to the library specific cleanup function.
    1.36 + * If the cleanup function is not in the common library, the code that
    1.37 + * allocates the memory should call the library specific cleanup function.
    1.38 + * For instance, in the i18n library, any memory allocated statically must
    1.39 + * call ucln_i18n_registerCleanup() from the ucln_in.h header.  These library
    1.40 + * cleanup functions are needed in order to prevent a circular dependency
    1.41 + * between the common library and any other library.
    1.42 + *
    1.43 + * The order of the cleanup is very important.  In general, an API that
    1.44 + * depends on a second API should be cleaned up before the second API.
    1.45 + * For instance, the default converter in ustring depends upon the converter
    1.46 + * API.  So the default converter should be closed before the converter API
    1.47 + * has its cache flushed.  This will prevent any memory leaks due to
    1.48 + * reference counting.
    1.49 + *
    1.50 + * Please see common/ucln_cmn.{h,c} and i18n/ucln_in.{h,c} for examples.
    1.51 + */
    1.52 +
    1.53 +typedef enum ECleanupLibraryType {
    1.54 +    UCLN_START = -1,
    1.55 +    UCLN_CUSTOM,    /* Custom is for anyone else. */
    1.56 +    UCLN_LAYOUTEX,
    1.57 +    UCLN_LAYOUT,
    1.58 +    UCLN_IO,
    1.59 +    UCLN_I18N,
    1.60 +    UCLN_COMMON /* This must be the last one to cleanup. */
    1.61 +} ECleanupLibraryType;
    1.62 +
    1.63 +U_CDECL_BEGIN
    1.64 +typedef UBool U_CALLCONV cleanupFunc(void);
    1.65 +U_CDECL_END
    1.66 +
    1.67 +U_CAPI void U_EXPORT2 ucln_registerCleanup(ECleanupLibraryType type,
    1.68 +                                           cleanupFunc *func);
    1.69 +
    1.70 +#endif