2017-01-20 00:20:31 +00:00
|
|
|
// © 2016 and later: Unicode, Inc. and others.
|
2016-06-15 18:58:17 +00:00
|
|
|
// License & terms of use: http://www.unicode.org/copyright.html
|
2001-08-30 03:06:19 +00:00
|
|
|
/*
|
|
|
|
******************************************************************************
|
2011-06-03 05:23:57 +00:00
|
|
|
*
|
2016-05-31 21:45:07 +00:00
|
|
|
* Copyright (C) 2001-2013, International Business Machines
|
2011-06-03 05:23:57 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
2001-08-30 03:06:19 +00:00
|
|
|
******************************************************************************
|
2011-06-03 05:23:57 +00:00
|
|
|
* file name: ucln.h
|
2001-08-30 03:06:19 +00:00
|
|
|
* encoding: US-ASCII
|
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:4
|
|
|
|
*
|
|
|
|
* created on: 2001July05
|
|
|
|
* created by: George Rhoten
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __UCLN_H__
|
|
|
|
#define __UCLN_H__
|
|
|
|
|
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
2001-09-20 22:55:34 +00:00
|
|
|
/** These are the functions used to register a library's memory cleanup
|
|
|
|
* functions. Each library should define a single library register function
|
|
|
|
* to call this API. In the i18n library, it is ucln_i18n_registerCleanup().
|
|
|
|
*
|
2001-11-13 22:41:35 +00:00
|
|
|
* None of the cleanup functions should use a mutex to clean up an API's
|
2001-09-20 22:55:34 +00:00
|
|
|
* allocated memory because a cleanup function is not meant to be thread safe,
|
|
|
|
* and plenty of data cannot be reference counted in order to make sure that
|
|
|
|
* no one else needs the allocated data.
|
|
|
|
*
|
|
|
|
* In order to make a cleanup function get called when u_cleanup is called,
|
|
|
|
* You should add your function to the library specific cleanup function.
|
|
|
|
* If the cleanup function is not in the common library, the code that
|
|
|
|
* allocates the memory should call the library specific cleanup function.
|
|
|
|
* For instance, in the i18n library, any memory allocated statically must
|
|
|
|
* call ucln_i18n_registerCleanup() from the ucln_in.h header. These library
|
|
|
|
* cleanup functions are needed in order to prevent a circular dependency
|
|
|
|
* between the common library and any other library.
|
|
|
|
*
|
|
|
|
* The order of the cleanup is very important. In general, an API that
|
|
|
|
* depends on a second API should be cleaned up before the second API.
|
|
|
|
* For instance, the default converter in ustring depends upon the converter
|
|
|
|
* API. So the default converter should be closed before the converter API
|
|
|
|
* has its cache flushed. This will prevent any memory leaks due to
|
|
|
|
* reference counting.
|
|
|
|
*
|
|
|
|
* Please see common/ucln_cmn.{h,c} and i18n/ucln_in.{h,c} for examples.
|
|
|
|
*/
|
|
|
|
|
2009-09-03 20:40:02 +00:00
|
|
|
/**
|
|
|
|
* Data Type for cleanup function selector. These roughly correspond to libraries.
|
|
|
|
*/
|
2001-09-20 22:55:34 +00:00
|
|
|
typedef enum ECleanupLibraryType {
|
2001-08-30 03:06:19 +00:00
|
|
|
UCLN_START = -1,
|
2010-01-09 02:15:20 +00:00
|
|
|
UCLN_UPLUG, /* ICU plugins */
|
2001-08-31 02:14:47 +00:00
|
|
|
UCLN_CUSTOM, /* Custom is for anyone else. */
|
2007-07-17 05:57:55 +00:00
|
|
|
UCLN_CTESTFW,
|
2010-05-12 17:56:02 +00:00
|
|
|
UCLN_TOOLUTIL,
|
2003-04-23 23:06:36 +00:00
|
|
|
UCLN_LAYOUTEX,
|
2004-02-10 19:07:21 +00:00
|
|
|
UCLN_LAYOUT,
|
2004-04-01 00:21:58 +00:00
|
|
|
UCLN_IO,
|
2001-08-30 03:06:19 +00:00
|
|
|
UCLN_I18N,
|
|
|
|
UCLN_COMMON /* This must be the last one to cleanup. */
|
2001-09-20 22:55:34 +00:00
|
|
|
} ECleanupLibraryType;
|
2001-08-30 03:06:19 +00:00
|
|
|
|
2009-09-03 20:40:02 +00:00
|
|
|
/**
|
|
|
|
* Data type for cleanup function pointer
|
|
|
|
*/
|
2004-09-12 22:54:50 +00:00
|
|
|
U_CDECL_BEGIN
|
|
|
|
typedef UBool U_CALLCONV cleanupFunc(void);
|
2012-08-11 04:57:13 +00:00
|
|
|
typedef void U_CALLCONV initFunc(UErrorCode *);
|
2004-09-12 22:54:50 +00:00
|
|
|
U_CDECL_END
|
2001-08-30 03:06:19 +00:00
|
|
|
|
2009-09-03 20:40:02 +00:00
|
|
|
/**
|
|
|
|
* Register a cleanup function
|
|
|
|
* @param type which library to register for.
|
|
|
|
* @param func the function pointer
|
|
|
|
*/
|
2001-08-30 03:06:19 +00:00
|
|
|
U_CAPI void U_EXPORT2 ucln_registerCleanup(ECleanupLibraryType type,
|
|
|
|
cleanupFunc *func);
|
|
|
|
|
2009-09-03 20:40:02 +00:00
|
|
|
/**
|
|
|
|
* Request cleanup for one specific library.
|
|
|
|
* Not thread safe.
|
|
|
|
* @param type which library to cleanup
|
|
|
|
*/
|
|
|
|
U_CAPI void U_EXPORT2 ucln_cleanupOne(ECleanupLibraryType type);
|
|
|
|
|
2001-08-30 03:06:19 +00:00
|
|
|
#endif
|