annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/unicode/uclean.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 // © 2016 and later: Unicode, Inc. and others.
jpayne@69 2 // License & terms of use: http://www.unicode.org/copyright.html
jpayne@69 3 /*
jpayne@69 4 ******************************************************************************
jpayne@69 5 * Copyright (C) 2001-2014, International Business Machines
jpayne@69 6 * Corporation and others. All Rights Reserved.
jpayne@69 7 ******************************************************************************
jpayne@69 8 * file name: uclean.h
jpayne@69 9 * encoding: UTF-8
jpayne@69 10 * tab size: 8 (not used)
jpayne@69 11 * indentation:4
jpayne@69 12 *
jpayne@69 13 * created on: 2001July05
jpayne@69 14 * created by: George Rhoten
jpayne@69 15 */
jpayne@69 16
jpayne@69 17 #ifndef __UCLEAN_H__
jpayne@69 18 #define __UCLEAN_H__
jpayne@69 19
jpayne@69 20 #include "unicode/utypes.h"
jpayne@69 21 /**
jpayne@69 22 * \file
jpayne@69 23 * \brief C API: Initialize and clean up ICU
jpayne@69 24 */
jpayne@69 25
jpayne@69 26 /**
jpayne@69 27 * Initialize ICU.
jpayne@69 28 *
jpayne@69 29 * Use of this function is optional. It is OK to simply use ICU
jpayne@69 30 * services and functions without first having initialized
jpayne@69 31 * ICU by calling u_init().
jpayne@69 32 *
jpayne@69 33 * u_init() will attempt to load some part of ICU's data, and is
jpayne@69 34 * useful as a test for configuration or installation problems that
jpayne@69 35 * leave the ICU data inaccessible. A successful invocation of u_init()
jpayne@69 36 * does not, however, guarantee that all ICU data is accessible.
jpayne@69 37 *
jpayne@69 38 * Multiple calls to u_init() cause no harm, aside from the small amount
jpayne@69 39 * of time required.
jpayne@69 40 *
jpayne@69 41 * In old versions of ICU, u_init() was required in multi-threaded applications
jpayne@69 42 * to ensure the thread safety of ICU. u_init() is no longer needed for this purpose.
jpayne@69 43 *
jpayne@69 44 * @param status An ICU UErrorCode parameter. It must not be <code>NULL</code>.
jpayne@69 45 * An Error will be returned if some required part of ICU data can not
jpayne@69 46 * be loaded or initialized.
jpayne@69 47 * The function returns immediately if the input error code indicates a
jpayne@69 48 * failure, as usual.
jpayne@69 49 *
jpayne@69 50 * @stable ICU 2.6
jpayne@69 51 */
jpayne@69 52 U_STABLE void U_EXPORT2
jpayne@69 53 u_init(UErrorCode *status);
jpayne@69 54
jpayne@69 55 #ifndef U_HIDE_SYSTEM_API
jpayne@69 56 /**
jpayne@69 57 * Clean up the system resources, such as allocated memory or open files,
jpayne@69 58 * used in all ICU libraries. This will free/delete all memory owned by the
jpayne@69 59 * ICU libraries, and return them to their original load state. All open ICU
jpayne@69 60 * items (collators, resource bundles, converters, etc.) must be closed before
jpayne@69 61 * calling this function, otherwise ICU may not free its allocated memory
jpayne@69 62 * (e.g. close your converters and resource bundles before calling this
jpayne@69 63 * function). Generally, this function should be called once just before
jpayne@69 64 * an application exits. For applications that dynamically load and unload
jpayne@69 65 * the ICU libraries (relatively uncommon), u_cleanup() should be called
jpayne@69 66 * just before the library unload.
jpayne@69 67 * <p>
jpayne@69 68 * u_cleanup() also clears any ICU heap functions, mutex functions or
jpayne@69 69 * trace functions that may have been set for the process.
jpayne@69 70 * This has the effect of restoring ICU to its initial condition, before
jpayne@69 71 * any of these override functions were installed. Refer to
jpayne@69 72 * u_setMemoryFunctions(), u_setMutexFunctions and
jpayne@69 73 * utrace_setFunctions(). If ICU is to be reinitialized after
jpayne@69 74 * calling u_cleanup(), these runtime override functions will need to
jpayne@69 75 * be set up again if they are still required.
jpayne@69 76 * <p>
jpayne@69 77 * u_cleanup() is not thread safe. All other threads should stop using ICU
jpayne@69 78 * before calling this function.
jpayne@69 79 * <p>
jpayne@69 80 * Any open ICU items will be left in an undefined state by u_cleanup(),
jpayne@69 81 * and any subsequent attempt to use such an item will give unpredictable
jpayne@69 82 * results.
jpayne@69 83 * <p>
jpayne@69 84 * After calling u_cleanup(), an application may continue to use ICU by
jpayne@69 85 * calling u_init(). An application must invoke u_init() first from one single
jpayne@69 86 * thread before allowing other threads call u_init(). All threads existing
jpayne@69 87 * at the time of the first thread's call to u_init() must also call
jpayne@69 88 * u_init() themselves before continuing with other ICU operations.
jpayne@69 89 * <p>
jpayne@69 90 * The use of u_cleanup() just before an application terminates is optional,
jpayne@69 91 * but it should be called only once for performance reasons. The primary
jpayne@69 92 * benefit is to eliminate reports of memory or resource leaks originating
jpayne@69 93 * in ICU code from the results generated by heap analysis tools.
jpayne@69 94 * <p>
jpayne@69 95 * <strong>Use this function with great care!</strong>
jpayne@69 96 * </p>
jpayne@69 97 *
jpayne@69 98 * @stable ICU 2.0
jpayne@69 99 * @system
jpayne@69 100 */
jpayne@69 101 U_STABLE void U_EXPORT2
jpayne@69 102 u_cleanup(void);
jpayne@69 103
jpayne@69 104 U_CDECL_BEGIN
jpayne@69 105 /**
jpayne@69 106 * Pointer type for a user supplied memory allocation function.
jpayne@69 107 * @param context user supplied value, obtained from u_setMemoryFunctions().
jpayne@69 108 * @param size The number of bytes to be allocated
jpayne@69 109 * @return Pointer to the newly allocated memory, or NULL if the allocation failed.
jpayne@69 110 * @stable ICU 2.8
jpayne@69 111 * @system
jpayne@69 112 */
jpayne@69 113 typedef void *U_CALLCONV UMemAllocFn(const void *context, size_t size);
jpayne@69 114 /**
jpayne@69 115 * Pointer type for a user supplied memory re-allocation function.
jpayne@69 116 * @param context user supplied value, obtained from u_setMemoryFunctions().
jpayne@69 117 * @param size The number of bytes to be allocated
jpayne@69 118 * @return Pointer to the newly allocated memory, or NULL if the allocation failed.
jpayne@69 119 * @stable ICU 2.8
jpayne@69 120 * @system
jpayne@69 121 */
jpayne@69 122 typedef void *U_CALLCONV UMemReallocFn(const void *context, void *mem, size_t size);
jpayne@69 123 /**
jpayne@69 124 * Pointer type for a user supplied memory free function. Behavior should be
jpayne@69 125 * similar the standard C library free().
jpayne@69 126 * @param context user supplied value, obtained from u_setMemoryFunctions().
jpayne@69 127 * @param mem Pointer to the memory block to be resized
jpayne@69 128 * @param size The new size for the block
jpayne@69 129 * @return Pointer to the resized memory block, or NULL if the resizing failed.
jpayne@69 130 * @stable ICU 2.8
jpayne@69 131 * @system
jpayne@69 132 */
jpayne@69 133 typedef void U_CALLCONV UMemFreeFn (const void *context, void *mem);
jpayne@69 134
jpayne@69 135 /**
jpayne@69 136 * Set the functions that ICU will use for memory allocation.
jpayne@69 137 * Use of this function is optional; by default (without this function), ICU will
jpayne@69 138 * use the standard C library malloc() and free() functions.
jpayne@69 139 * This function can only be used when ICU is in an initial, unused state, before
jpayne@69 140 * u_init() has been called.
jpayne@69 141 * @param context This pointer value will be saved, and then (later) passed as
jpayne@69 142 * a parameter to the memory functions each time they
jpayne@69 143 * are called.
jpayne@69 144 * @param a Pointer to a user-supplied malloc function.
jpayne@69 145 * @param r Pointer to a user-supplied realloc function.
jpayne@69 146 * @param f Pointer to a user-supplied free function.
jpayne@69 147 * @param status Receives error values.
jpayne@69 148 * @stable ICU 2.8
jpayne@69 149 * @system
jpayne@69 150 */
jpayne@69 151 U_STABLE void U_EXPORT2
jpayne@69 152 u_setMemoryFunctions(const void *context, UMemAllocFn * U_CALLCONV_FPTR a, UMemReallocFn * U_CALLCONV_FPTR r, UMemFreeFn * U_CALLCONV_FPTR f,
jpayne@69 153 UErrorCode *status);
jpayne@69 154
jpayne@69 155 U_CDECL_END
jpayne@69 156
jpayne@69 157 #ifndef U_HIDE_DEPRECATED_API
jpayne@69 158 /*********************************************************************************
jpayne@69 159 *
jpayne@69 160 * Deprecated Functions
jpayne@69 161 *
jpayne@69 162 * The following functions for user supplied mutexes are no longer supported.
jpayne@69 163 * Any attempt to use them will return a U_UNSUPPORTED_ERROR.
jpayne@69 164 *
jpayne@69 165 **********************************************************************************/
jpayne@69 166
jpayne@69 167 /**
jpayne@69 168 * An opaque pointer type that represents an ICU mutex.
jpayne@69 169 * For user-implemented mutexes, the value will typically point to a
jpayne@69 170 * struct or object that implements the mutex.
jpayne@69 171 * @deprecated ICU 52. This type is no longer supported.
jpayne@69 172 * @system
jpayne@69 173 */
jpayne@69 174 typedef void *UMTX;
jpayne@69 175
jpayne@69 176 U_CDECL_BEGIN
jpayne@69 177 /**
jpayne@69 178 * Function Pointer type for a user supplied mutex initialization function.
jpayne@69 179 * The user-supplied function will be called by ICU whenever ICU needs to create a
jpayne@69 180 * new mutex. The function implementation should create a mutex, and store a pointer
jpayne@69 181 * to something that uniquely identifies the mutex into the UMTX that is supplied
jpayne@69 182 * as a parameter.
jpayne@69 183 * @param context user supplied value, obtained from u_setMutexFunctions().
jpayne@69 184 * @param mutex Receives a pointer that identifies the new mutex.
jpayne@69 185 * The mutex init function must set the UMTX to a non-null value.
jpayne@69 186 * Subsequent calls by ICU to lock, unlock, or destroy a mutex will
jpayne@69 187 * identify the mutex by the UMTX value.
jpayne@69 188 * @param status Error status. Report errors back to ICU by setting this variable
jpayne@69 189 * with an error code.
jpayne@69 190 * @deprecated ICU 52. This function is no longer supported.
jpayne@69 191 * @system
jpayne@69 192 */
jpayne@69 193 typedef void U_CALLCONV UMtxInitFn (const void *context, UMTX *mutex, UErrorCode* status);
jpayne@69 194
jpayne@69 195
jpayne@69 196 /**
jpayne@69 197 * Function Pointer type for a user supplied mutex functions.
jpayne@69 198 * One of the user-supplied functions with this signature will be called by ICU
jpayne@69 199 * whenever ICU needs to lock, unlock, or destroy a mutex.
jpayne@69 200 * @param context user supplied value, obtained from u_setMutexFunctions().
jpayne@69 201 * @param mutex specify the mutex on which to operate.
jpayne@69 202 * @deprecated ICU 52. This function is no longer supported.
jpayne@69 203 * @system
jpayne@69 204 */
jpayne@69 205 typedef void U_CALLCONV UMtxFn (const void *context, UMTX *mutex);
jpayne@69 206 U_CDECL_END
jpayne@69 207
jpayne@69 208 /**
jpayne@69 209 * Set the functions that ICU will use for mutex operations
jpayne@69 210 * Use of this function is optional; by default (without this function), ICU will
jpayne@69 211 * directly access system functions for mutex operations
jpayne@69 212 * This function can only be used when ICU is in an initial, unused state, before
jpayne@69 213 * u_init() has been called.
jpayne@69 214 * @param context This pointer value will be saved, and then (later) passed as
jpayne@69 215 * a parameter to the user-supplied mutex functions each time they
jpayne@69 216 * are called.
jpayne@69 217 * @param init Pointer to a mutex initialization function. Must be non-null.
jpayne@69 218 * @param destroy Pointer to the mutex destroy function. Must be non-null.
jpayne@69 219 * @param lock pointer to the mutex lock function. Must be non-null.
jpayne@69 220 * @param unlock Pointer to the mutex unlock function. Must be non-null.
jpayne@69 221 * @param status Receives error values.
jpayne@69 222 * @deprecated ICU 52. This function is no longer supported.
jpayne@69 223 * @system
jpayne@69 224 */
jpayne@69 225 U_DEPRECATED void U_EXPORT2
jpayne@69 226 u_setMutexFunctions(const void *context, UMtxInitFn *init, UMtxFn *destroy, UMtxFn *lock, UMtxFn *unlock,
jpayne@69 227 UErrorCode *status);
jpayne@69 228
jpayne@69 229
jpayne@69 230 /**
jpayne@69 231 * Pointer type for a user supplied atomic increment or decrement function.
jpayne@69 232 * @param context user supplied value, obtained from u_setAtomicIncDecFunctions().
jpayne@69 233 * @param p Pointer to a 32 bit int to be incremented or decremented
jpayne@69 234 * @return The value of the variable after the inc or dec operation.
jpayne@69 235 * @deprecated ICU 52. This function is no longer supported.
jpayne@69 236 * @system
jpayne@69 237 */
jpayne@69 238 typedef int32_t U_CALLCONV UMtxAtomicFn(const void *context, int32_t *p);
jpayne@69 239
jpayne@69 240 /**
jpayne@69 241 * Set the functions that ICU will use for atomic increment and decrement of int32_t values.
jpayne@69 242 * Use of this function is optional; by default (without this function), ICU will
jpayne@69 243 * use its own internal implementation of atomic increment/decrement.
jpayne@69 244 * This function can only be used when ICU is in an initial, unused state, before
jpayne@69 245 * u_init() has been called.
jpayne@69 246 * @param context This pointer value will be saved, and then (later) passed as
jpayne@69 247 * a parameter to the increment and decrement functions each time they
jpayne@69 248 * are called. This function can only be called
jpayne@69 249 * @param inc Pointer to a function to do an atomic increment operation. Must be non-null.
jpayne@69 250 * @param dec Pointer to a function to do an atomic decrement operation. Must be non-null.
jpayne@69 251 * @param status Receives error values.
jpayne@69 252 * @deprecated ICU 52. This function is no longer supported.
jpayne@69 253 * @system
jpayne@69 254 */
jpayne@69 255 U_DEPRECATED void U_EXPORT2
jpayne@69 256 u_setAtomicIncDecFunctions(const void *context, UMtxAtomicFn *inc, UMtxAtomicFn *dec,
jpayne@69 257 UErrorCode *status);
jpayne@69 258
jpayne@69 259 #endif /* U_HIDE_DEPRECATED_API */
jpayne@69 260 #endif /* U_HIDE_SYSTEM_API */
jpayne@69 261
jpayne@69 262 #endif