intl/icu/source/common/ucln.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/common/ucln.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,89 @@
     1.4 +/*
     1.5 +******************************************************************************
     1.6 +*
     1.7 +* Copyright (C) 2001-2013, International Business Machines
     1.8 +*                Corporation and others. All Rights Reserved.
     1.9 +*
    1.10 +******************************************************************************
    1.11 +*   file name:  ucln.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 +/**
    1.54 + * Data Type for cleanup function selector. These roughly correspond to libraries.
    1.55 + */
    1.56 +typedef enum ECleanupLibraryType {
    1.57 +    UCLN_START = -1,
    1.58 +    UCLN_UPLUG,     /* ICU plugins */
    1.59 +    UCLN_CUSTOM,    /* Custom is for anyone else. */
    1.60 +    UCLN_CTESTFW,
    1.61 +    UCLN_TOOLUTIL,
    1.62 +    UCLN_LAYOUTEX,
    1.63 +    UCLN_LAYOUT,
    1.64 +    UCLN_IO,
    1.65 +    UCLN_I18N,
    1.66 +    UCLN_COMMON /* This must be the last one to cleanup. */
    1.67 +} ECleanupLibraryType;
    1.68 +
    1.69 +/**
    1.70 + * Data type for cleanup function pointer
    1.71 + */
    1.72 +U_CDECL_BEGIN
    1.73 +typedef UBool U_CALLCONV cleanupFunc(void);
    1.74 +typedef void U_CALLCONV initFunc(UErrorCode *);
    1.75 +U_CDECL_END
    1.76 +
    1.77 +/**
    1.78 + * Register a cleanup function
    1.79 + * @param type which library to register for.
    1.80 + * @param func the function pointer
    1.81 + */
    1.82 +U_CAPI void U_EXPORT2 ucln_registerCleanup(ECleanupLibraryType type,
    1.83 +                                           cleanupFunc *func);
    1.84 +
    1.85 +/**
    1.86 + * Request cleanup for one specific library.
    1.87 + * Not thread safe.
    1.88 + * @param type which library to cleanup
    1.89 + */
    1.90 +U_CAPI void U_EXPORT2 ucln_cleanupOne(ECleanupLibraryType type);
    1.91 +
    1.92 +#endif

mercurial