From 2a17db6667dfb548372ba9df0c31b6ab52ae4b66 Mon Sep 17 00:00:00 2001 From: Jim Snyder Grant Date: Fri, 16 Feb 2001 22:21:14 +0000 Subject: [PATCH] ICU-388 and jb 853: ucnv_safeClone X-SVN-Rev: 3656 --- icu4c/source/common/unicode/ucnv.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/icu4c/source/common/unicode/ucnv.h b/icu4c/source/common/unicode/ucnv.h index 2e4867cb868..046f1379869 100644 --- a/icu4c/source/common/unicode/ucnv.h +++ b/icu4c/source/common/unicode/ucnv.h @@ -263,6 +263,32 @@ ucnv_openCCSID (int32_t codepage, UConverterPlatform platform, UErrorCode * err); +/** + * Thread safe cloning operation + * @param cnv converter to be cloned + * @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated. + If buffer is not large enough, new memory will be allocated. + Clients can use the U_CNV_SAFECLONE_BUFFERSIZE. This will probably be enough to avoid memory allocations. + * @param pBufferSize pointer to size of allocated space. + If *pBufferSize == 0, a sufficient size for use in cloning will + be returned ('pre-flighting') + If *pBufferSize is not enough for a stack-based safe clone, + new memory will be allocated. + * @param status to indicate whether the operation went on smoothly or there were errors + An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any allocations were necessary. + * @return pointer to the new clone + * @draft API 1.8 freeze + */ + +U_CAPI UConverter * + ucnv_safeClone( + const UConverter *cnv, + void *stackBuffer, + int32_t *pBufferSize, + UErrorCode *status); + +#define U_CNV_SAFECLONE_BUFFERSIZE 512 + /** * Deletes the unicode converter and releases resources associated * with just this instance. @@ -275,6 +301,9 @@ ucnv_openCCSID (int32_t codepage, * @stable */ + + + U_CAPI void U_EXPORT2 ucnv_close (UConverter * converter);