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