From: Markus Scherer Date: Tue, 17 Sep 2013 19:48:50 +0000 (+0000) Subject: ICU-9932 deprecate & disable cloning-into-user-buffer, except keep ucnv_safeClone... X-Git-Tag: milestone-59-0-1~2501 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=27e00900c8443acfd4d7e54f4b726afb1c200d30;p=icu ICU-9932 deprecate & disable cloning-into-user-buffer, except keep ucnv_safeClone() intact X-SVN-Rev: 34359 --- diff --git a/icu4c/source/common/brkiter.cpp b/icu4c/source/common/brkiter.cpp index 3b6c94dc611..adbfd6501aa 100644 --- a/icu4c/source/common/brkiter.cpp +++ b/icu4c/source/common/brkiter.cpp @@ -204,7 +204,6 @@ BreakIterator::getAvailableLocales(int32_t& count) BreakIterator::BreakIterator() { - fBufferClone = FALSE; *validLocale = *actualLocale = 0; } diff --git a/icu4c/source/common/rbbi.cpp b/icu4c/source/common/rbbi.cpp index 2f0d1ba99e5..6ab57a7c117 100644 --- a/icu4c/source/common/rbbi.cpp +++ b/icu4c/source/common/rbbi.cpp @@ -270,7 +270,6 @@ RuleBasedBreakIterator::operator=(const RuleBasedBreakIterator& that) { //----------------------------------------------------------------------------- void RuleBasedBreakIterator::init() { UErrorCode status = U_ZERO_ERROR; - fBufferClone = FALSE; fText = utext_openUChars(NULL, NULL, 0, &status); fCharIter = NULL; fSCharIter = NULL; @@ -1515,19 +1514,7 @@ const uint8_t *RuleBasedBreakIterator::getBinaryRules(uint32_t &length) { } - - -//------------------------------------------------------------------------------- -// -// BufferClone TODO: In my (Andy) opinion, this function should be deprecated. -// Saving one heap allocation isn't worth the trouble. -// Cloning shouldn't be done in tight loops, and -// making the clone copy involves other heap operations anyway. -// And the application code for correctly dealing with buffer -// size problems and the eventual object destruction is ugly. -// -//------------------------------------------------------------------------------- -BreakIterator * RuleBasedBreakIterator::createBufferClone(void *stackBuffer, +BreakIterator * RuleBasedBreakIterator::createBufferClone(void * /*stackBuffer*/, int32_t &bufferSize, UErrorCode &status) { @@ -1535,51 +1522,18 @@ BreakIterator * RuleBasedBreakIterator::createBufferClone(void *stackBuffer, return NULL; } - // - // If user buffer size is zero this is a preflight operation to - // obtain the needed buffer size, allowing for worst case misalignment. - // if (bufferSize == 0) { - bufferSize = sizeof(RuleBasedBreakIterator) + U_ALIGNMENT_OFFSET_UP(0); + bufferSize = 1; // preflighting for deprecated functionality return NULL; } - - // - // Check the alignment and size of the user supplied buffer. - // Allocate heap memory if the user supplied memory is insufficient. - // - char *buf = (char *)stackBuffer; - uint32_t s = bufferSize; - - if (stackBuffer == NULL) { - s = 0; // Ignore size, force allocation if user didn't give us a buffer. - } - if (U_ALIGNMENT_OFFSET(stackBuffer) != 0) { - uint32_t offsetUp = (uint32_t)U_ALIGNMENT_OFFSET_UP(buf); - s -= offsetUp; - buf += offsetUp; - } - if (s < sizeof(RuleBasedBreakIterator)) { - // Not enough room in the caller-supplied buffer. - // Do a plain-vanilla heap based clone and return that, along with - // a warning that the clone was allocated. - RuleBasedBreakIterator *clonedBI = new RuleBasedBreakIterator(*this); - if (clonedBI == 0) { - status = U_MEMORY_ALLOCATION_ERROR; - } else { - status = U_SAFECLONE_ALLOCATED_WARNING; - } - return clonedBI; + BreakIterator *clonedBI = clone(); + if (clonedBI == NULL) { + status = U_MEMORY_ALLOCATION_ERROR; + } else { + status = U_SAFECLONE_ALLOCATED_WARNING; } - - // - // Clone the source BI into the caller-supplied buffer. - // - RuleBasedBreakIterator *clone = new(buf) RuleBasedBreakIterator(*this); - clone->fBufferClone = TRUE; // Flag to prevent deleting storage on close (From C code) - - return clone; + return (RuleBasedBreakIterator *)clonedBI; } diff --git a/icu4c/source/common/ubrk.cpp b/icu4c/source/common/ubrk.cpp index 6ae60a38fab..a0002c21cea 100644 --- a/icu4c/source/common/ubrk.cpp +++ b/icu4c/source/common/ubrk.cpp @@ -1,6 +1,6 @@ /* ******************************************************************************** -* Copyright (C) 1996-2012, International Business Machines +* Copyright (C) 1996-2013, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************** */ @@ -123,25 +123,31 @@ ubrk_openRules( const UChar *rules, U_CAPI UBreakIterator * U_EXPORT2 ubrk_safeClone( const UBreakIterator *bi, - void *stackBuffer, + void * /*stackBuffer*/, int32_t *pBufferSize, UErrorCode *status) { if (status == NULL || U_FAILURE(*status)){ - return 0; + return NULL; } - if (!pBufferSize || !bi){ + if (bi == NULL) { *status = U_ILLEGAL_ARGUMENT_ERROR; - return 0; + return NULL; } - // Clear any incoming Safe Clone Allocated warning. - // Propagating this through to our return would really - // confuse our caller. - if (*status==U_SAFECLONE_ALLOCATED_WARNING) { - *status = U_ZERO_ERROR; + if (pBufferSize != NULL) { + int32_t inputSize = *pBufferSize; + *pBufferSize = 1; + if (inputSize == 0) { + return NULL; // preflighting for deprecated functionality + } + } + BreakIterator *newBI = ((BreakIterator *)bi)->clone(); + if (newBI == NULL) { + *status = U_MEMORY_ALLOCATION_ERROR; + } else { + *status = U_SAFECLONE_ALLOCATED_WARNING; } - return (UBreakIterator *)(((BreakIterator*)bi)-> - createBufferClone(stackBuffer, *pBufferSize, *status)); + return (UBreakIterator *)newBI; } @@ -149,15 +155,7 @@ ubrk_safeClone( U_CAPI void U_EXPORT2 ubrk_close(UBreakIterator *bi) { - BreakIterator *ubi = (BreakIterator*) bi; - if (ubi) { - if (ubi->isBufferClone()) { - ubi->~BreakIterator(); - *(uint32_t *)ubi = 0xdeadbeef; - } else { - delete ubi; - } - } + delete (BreakIterator *)bi; } U_CAPI void U_EXPORT2 @@ -170,7 +168,7 @@ ubrk_setText(UBreakIterator* bi, UText ut = UTEXT_INITIALIZER; utext_openUChars(&ut, text, textLength, status); brit->setText(&ut, *status); - // A stack allocated UText wrapping a UCHar * string + // A stack allocated UText wrapping a UChar * string // can be dumped without explicitly closing it. } diff --git a/icu4c/source/common/ucnv.c b/icu4c/source/common/ucnv.c index 52d4f6d6267..5cf4d15cc63 100644 --- a/icu4c/source/common/ucnv.c +++ b/icu4c/source/common/ucnv.c @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 1998-2012, International Business Machines +* Copyright (C) 1998-2013, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -154,6 +154,7 @@ U_CAPI UConverter* U_EXPORT2 ucnv_safeClone(const UConverter* cnv, void *stackBuffer, int32_t *pBufferSize, UErrorCode *status) { UConverter *localConverter, *allocatedConverter; + int32_t stackBufferSize; int32_t bufferSizeNeeded; char *stackBufferChars = (char *)stackBuffer; UErrorCode cbErr; @@ -182,13 +183,13 @@ ucnv_safeClone(const UConverter* cnv, void *stackBuffer, int32_t *pBufferSize, U if (status == NULL || U_FAILURE(*status)){ UTRACE_EXIT_STATUS(status? *status: U_ILLEGAL_ARGUMENT_ERROR); - return 0; + return NULL; } - if (!pBufferSize || !cnv){ + if (cnv == NULL) { *status = U_ILLEGAL_ARGUMENT_ERROR; UTRACE_EXIT_STATUS(*status); - return 0; + return NULL; } UTRACE_DATA3(UTRACE_OPEN_CLOSE, "clone converter %s at %p into stackBuffer %p", @@ -198,6 +199,10 @@ ucnv_safeClone(const UConverter* cnv, void *stackBuffer, int32_t *pBufferSize, U /* call the custom safeClone function for sizing */ bufferSizeNeeded = 0; cnv->sharedData->impl->safeClone(cnv, NULL, &bufferSizeNeeded, status); + if (U_FAILURE(*status)) { + UTRACE_EXIT_STATUS(*status); + return NULL; + } } else { @@ -205,10 +210,16 @@ ucnv_safeClone(const UConverter* cnv, void *stackBuffer, int32_t *pBufferSize, U bufferSizeNeeded = sizeof(UConverter); } - if (*pBufferSize <= 0){ /* 'preflighting' request - set needed size into *pBufferSize */ - *pBufferSize = bufferSizeNeeded; - UTRACE_EXIT_VALUE(bufferSizeNeeded); - return 0; + if (pBufferSize == NULL) { + stackBufferSize = 1; + pBufferSize = &stackBufferSize; + } else { + stackBufferSize = *pBufferSize; + if (stackBufferSize <= 0){ /* 'preflighting' request - set needed size into *pBufferSize */ + *pBufferSize = bufferSizeNeeded; + UTRACE_EXIT_VALUE(bufferSizeNeeded); + return NULL; + } } @@ -217,19 +228,19 @@ ucnv_safeClone(const UConverter* cnv, void *stackBuffer, int32_t *pBufferSize, U */ if (U_ALIGNMENT_OFFSET(stackBuffer) != 0) { int32_t offsetUp = (int32_t)U_ALIGNMENT_OFFSET_UP(stackBufferChars); - if(*pBufferSize > offsetUp) { - *pBufferSize -= offsetUp; + if(stackBufferSize > offsetUp) { + stackBufferSize -= offsetUp; stackBufferChars += offsetUp; } else { /* prevent using the stack buffer but keep the size > 0 so that we do not just preflight */ - *pBufferSize = 1; + stackBufferSize = 1; } } stackBuffer = (void *)stackBufferChars; /* Now, see if we must allocate any memory */ - if (*pBufferSize < bufferSizeNeeded || stackBuffer == NULL) + if (stackBufferSize < bufferSizeNeeded || stackBuffer == NULL) { /* allocate one here...*/ localConverter = allocatedConverter = (UConverter *) uprv_malloc (bufferSizeNeeded); @@ -239,11 +250,8 @@ ucnv_safeClone(const UConverter* cnv, void *stackBuffer, int32_t *pBufferSize, U UTRACE_EXIT_STATUS(*status); return NULL; } - - if (U_SUCCESS(*status)) { - *status = U_SAFECLONE_ALLOCATED_WARNING; - } - + *status = U_SAFECLONE_ALLOCATED_WARNING; + /* record the fact that memory was allocated */ *pBufferSize = bufferSizeNeeded; } else { diff --git a/icu4c/source/common/unicode/brkiter.h b/icu4c/source/common/unicode/brkiter.h index 947059a801f..4e601bad899 100644 --- a/icu4c/source/common/unicode/brkiter.h +++ b/icu4c/source/common/unicode/brkiter.h @@ -486,6 +486,8 @@ public: UnicodeString& name); /** + * Deprecated functionality. Use clone() instead. + * * Thread safe client-buffer-based cloning operation * Do NOT call delete on a safeclone, since 'new' is not used to create it. * @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated. @@ -500,20 +502,24 @@ public: * necessary. * @return pointer to the new clone * - * @stable ICU 2.0 + * @deprecated ICU 52. Use clone() instead. */ virtual BreakIterator * createBufferClone(void *stackBuffer, int32_t &BufferSize, UErrorCode &status) = 0; +#ifndef U_HIDE_DEPRECATED_API + /** * Determine whether the BreakIterator was created in user memory by * createBufferClone(), and thus should not be deleted. Such objects * must be closed by an explicit call to the destructor (not delete). - * @stable ICU 2.0 + * @deprecated ICU 52. Always delete the BreakIterator. */ inline UBool isBufferClone(void); +#endif /* U_HIDE_DEPRECATED_API */ + #if !UCONFIG_NO_SERVICE /** * Register a new break iterator of the indicated kind, to use in the given locale. @@ -610,9 +616,7 @@ protected: /** @internal */ BreakIterator(); /** @internal */ - UBool fBufferClone; - /** @internal */ - BreakIterator (const BreakIterator &other) : UObject(other), fBufferClone(FALSE) {} + BreakIterator (const BreakIterator &other) : UObject(other) {} private: @@ -627,15 +631,18 @@ private: BreakIterator& operator=(const BreakIterator&); }; +#ifndef U_HIDE_DEPRECATED_API + inline UBool BreakIterator::isBufferClone() { - return fBufferClone; + return FALSE; } +#endif /* U_HIDE_DEPRECATED_API */ + U_NAMESPACE_END #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ #endif // _BRKITER //eof - diff --git a/icu4c/source/common/unicode/rbbi.h b/icu4c/source/common/unicode/rbbi.h index 15993781731..aa6cf47ba42 100644 --- a/icu4c/source/common/unicode/rbbi.h +++ b/icu4c/source/common/unicode/rbbi.h @@ -583,7 +583,9 @@ public: */ static UClassID U_EXPORT2 getStaticClassID(void); - /* + /** + * Deprecated functionality. Use clone() instead. + * * Create a clone (copy) of this break iterator in memory provided * by the caller. The idea is to increase performance by avoiding * a storage allocation. Use of this functoin is NOT RECOMMENDED. @@ -605,7 +607,7 @@ public: * @return Pointer to the clone object. This may differ from the stackBuffer * address if the byte alignment of the stack buffer was not suitable * or if the stackBuffer was too small to hold the clone. - * @stable ICU 2.0 + * @deprecated ICU 52. Use clone() instead. */ virtual BreakIterator * createBufferClone(void *stackBuffer, int32_t &BufferSize, @@ -697,7 +699,6 @@ protected: #ifndef U_HIDE_INTERNAL_API /** * Common initialization function, used by constructors and bufferClone. - * (Also used by DictionaryBasedBreakIterator::createBufferClone().) * @internal */ void init(); diff --git a/icu4c/source/common/unicode/ubrk.h b/icu4c/source/common/unicode/ubrk.h index 2506540dfb5..e9c0ef627b6 100644 --- a/icu4c/source/common/unicode/ubrk.h +++ b/icu4c/source/common/unicode/ubrk.h @@ -243,10 +243,12 @@ ubrk_openRules(const UChar *rules, /** * Thread safe cloning operation * @param bi iterator to be cloned - * @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated. + * @param stackBuffer Deprecated functionality as of ICU 52, use NULL.
+ * 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_BRK_SAFECLONE_BUFFERSIZE. This will probably be enough to avoid memory allocations. - * @param pBufferSize pointer to size of allocated space. + * Clients can use the U_BRK_SAFECLONE_BUFFERSIZE. + * @param pBufferSize Deprecated functionality as of ICU 52, use NULL or 1.
+ * 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, @@ -263,11 +265,15 @@ ubrk_safeClone( int32_t *pBufferSize, UErrorCode *status); +#ifndef U_HIDE_DEPRECATED_API + /** * A recommended size (in bytes) for the memory buffer to be passed to ubrk_saveClone(). - * @stable ICU 2.0 + * @deprecated ICU 52. Do not rely on ubrk_safeClone() cloning into any provided buffer. */ -#define U_BRK_SAFECLONE_BUFFERSIZE 528 +#define U_BRK_SAFECLONE_BUFFERSIZE 1 + +#endif /* U_HIDE_DEPRECATED_API */ /** * Close a UBreakIterator. diff --git a/icu4c/source/common/unicode/ucnv.h b/icu4c/source/common/unicode/ucnv.h index 183573a14fb..c5fc2dc7856 100644 --- a/icu4c/source/common/unicode/ucnv.h +++ b/icu4c/source/common/unicode/ucnv.h @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 1999-2012, International Business Machines +* Copyright (C) 1999-2013, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * ucnv.h: @@ -521,10 +521,12 @@ ucnv_openPackage(const char *packageName, const char *converterName, UErrorCode * adjusted pointer and use an accordingly smaller buffer size. * * @param cnv converter to be cloned - * @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated. + * @param stackBuffer Deprecated functionality as of ICU 52, use NULL.
+ * 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. pBufferSize must not be NULL. + * @param pBufferSize Deprecated functionality as of ICU 52, use NULL or 1.
+ * pointer to size of allocated space. * @param status to indicate whether the operation went on smoothly or there were errors * An informational status value, U_SAFECLONE_ALLOCATED_WARNING, * is used if any allocations were necessary. @@ -540,14 +542,18 @@ ucnv_safeClone(const UConverter *cnv, int32_t *pBufferSize, UErrorCode *status); +#ifndef U_HIDE_DEPRECATED_API + /** * \def U_CNV_SAFECLONE_BUFFERSIZE * Definition of a buffer size that is designed to be large enough for * converters to be cloned with ucnv_safeClone(). - * @stable ICU 2.0 + * @deprecated ICU 52. Do not rely on ucnv_safeClone() cloning into any provided buffer. */ #define U_CNV_SAFECLONE_BUFFERSIZE 1024 +#endif /* U_HIDE_DEPRECATED_API */ + /** * Deletes the unicode converter and releases resources associated * with just this instance. diff --git a/icu4c/source/i18n/tblcoll.cpp b/icu4c/source/i18n/tblcoll.cpp index 75458542ff8..744600d18c6 100644 --- a/icu4c/source/i18n/tblcoll.cpp +++ b/icu4c/source/i18n/tblcoll.cpp @@ -209,8 +209,7 @@ RuleBasedCollator& RuleBasedCollator::operator=(const RuleBasedCollator& that) if (this == &that) { return *this; } UErrorCode intStatus = U_ZERO_ERROR; - int32_t buffersize = U_COL_SAFECLONE_BUFFERSIZE; - UCollator *ucol = ucol_safeClone(that.ucollator, NULL, &buffersize, &intStatus); + UCollator *ucol = ucol_safeClone(that.ucollator, NULL, NULL, &intStatus); if (U_FAILURE(intStatus)) { return *this; } if (dataIsOwned) { diff --git a/icu4c/source/i18n/ucol.cpp b/icu4c/source/i18n/ucol.cpp index c8febdf2d2d..d60ad8152f0 100644 --- a/icu4c/source/i18n/ucol.cpp +++ b/icu4c/source/i18n/ucol.cpp @@ -556,11 +556,10 @@ ucol_cloneBinary(const UCollator *coll, } U_CAPI UCollator* U_EXPORT2 -ucol_safeClone(const UCollator *coll, void *stackBuffer, int32_t * pBufferSize, UErrorCode *status) +ucol_safeClone(const UCollator *coll, void * /*stackBuffer*/, int32_t * pBufferSize, UErrorCode *status) { UCollator * localCollator; int32_t bufferSizeNeeded = (int32_t)sizeof(UCollator); - char *stackBufferChars = (char *)stackBuffer; int32_t imageSize = 0; int32_t rulesSize = 0; int32_t rulesPadding = 0; @@ -571,15 +570,14 @@ ucol_safeClone(const UCollator *coll, void *stackBuffer, int32_t * pBufferSize, int32_t* defaultReorderCodes; int32_t* reorderCodes; uint8_t* leadBytePermutationTable; - UBool colAllocated = FALSE; UBool imageAllocated = FALSE; if (status == NULL || U_FAILURE(*status)){ - return 0; + return NULL; } - if ((stackBuffer && !pBufferSize) || !coll){ + if (coll == NULL) { *status = U_ILLEGAL_ARGUMENT_ERROR; - return 0; + return NULL; } if (coll->rules && coll->freeRulesOnClose) { @@ -599,41 +597,23 @@ ucol_safeClone(const UCollator *coll, void *stackBuffer, int32_t * pBufferSize, if (coll->leadBytePermutationTable) { bufferSizeNeeded += 256 * sizeof(uint8_t); } - - if (stackBuffer && *pBufferSize <= 0) { /* 'preflighting' request - set needed size into *pBufferSize */ - *pBufferSize = bufferSizeNeeded; - return 0; - } - /* Pointers on 64-bit platforms need to be aligned - * on a 64-bit boundry in memory. - */ - if (U_ALIGNMENT_OFFSET(stackBuffer) != 0) { - int32_t offsetUp = (int32_t)U_ALIGNMENT_OFFSET_UP(stackBufferChars); - if (*pBufferSize > offsetUp) { - *pBufferSize -= offsetUp; - stackBufferChars += offsetUp; - } - else { - /* prevent using the stack buffer but keep the size > 0 so that we do not just preflight */ - *pBufferSize = 1; + if (pBufferSize != NULL) { + int32_t inputSize = *pBufferSize; + *pBufferSize = 1; + if (inputSize == 0) { + return NULL; // preflighting for deprecated functionality } } - stackBuffer = (void *)stackBufferChars; - if (stackBuffer == NULL || *pBufferSize < bufferSizeNeeded) { - /* allocate one here...*/ - stackBufferChars = (char *)uprv_malloc(bufferSizeNeeded); - // Null pointer check. - if (stackBufferChars == NULL) { - *status = U_MEMORY_ALLOCATION_ERROR; - return NULL; - } - colAllocated = TRUE; - if (U_SUCCESS(*status)) { - *status = U_SAFECLONE_ALLOCATED_WARNING; - } + char *stackBufferChars = (char *)uprv_malloc(bufferSizeNeeded); + // Null pointer check. + if (stackBufferChars == NULL) { + *status = U_MEMORY_ALLOCATION_ERROR; + return NULL; } + *status = U_SAFECLONE_ALLOCATED_WARNING; + localCollator = (UCollator *)stackBufferChars; rules = (UChar *)(stackBufferChars + sizeof(UCollator) + rulesPadding); defaultReorderCodes = (int32_t*)((uint8_t*)rules + rulesSize); @@ -702,7 +682,7 @@ ucol_safeClone(const UCollator *coll, void *stackBuffer, int32_t * pBufferSize, localCollator->validLocale = NULL; localCollator->requestedLocale = NULL; localCollator->ucaRules = coll->ucaRules; // There should only be one copy here. - localCollator->freeOnClose = colAllocated; + localCollator->freeOnClose = TRUE; localCollator->freeImageOnClose = imageAllocated; return localCollator; } diff --git a/icu4c/source/i18n/unicode/ucol.h b/icu4c/source/i18n/unicode/ucol.h index 41fdc317bc1..3bb4bc1c3dc 100644 --- a/icu4c/source/i18n/unicode/ucol.h +++ b/icu4c/source/i18n/unicode/ucol.h @@ -1212,12 +1212,13 @@ ucol_restoreVariableTop(UCollator *coll, const uint32_t varTop, UErrorCode *stat /** * Thread safe cloning operation. The result is a clone of a given collator. * @param coll collator to be cloned - * @param stackBuffer user allocated space for the new clone. + * @param stackBuffer Deprecated functionality as of ICU 52, use NULL.
+ * 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_COL_SAFECLONE_BUFFERSIZE. - * This will probably be enough to avoid memory allocations. - * @param pBufferSize pointer to size of allocated space. + * Clients can use the U_COL_SAFECLONE_BUFFERSIZE. + * @param pBufferSize Deprecated functionality as of ICU 52, use NULL or 1.
+ * 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, @@ -1237,10 +1238,14 @@ ucol_safeClone(const UCollator *coll, int32_t *pBufferSize, UErrorCode *status); -/** default memory size for the new clone. It needs to be this large for os/400 large pointers - * @stable ICU 2.0 +#ifndef U_HIDE_DEPRECATED_API + +/** default memory size for the new clone. + * @deprecated ICU 52. Do not rely on ucol_safeClone() cloning into any provided buffer. */ -#define U_COL_SAFECLONE_BUFFERSIZE 528 +#define U_COL_SAFECLONE_BUFFERSIZE 1 + +#endif /* U_HIDE_DEPRECATED_API */ /** * Returns current rules. Delta defines whether full rules are returned or just the tailoring. diff --git a/icu4c/source/samples/ucnv/convsamp.cpp b/icu4c/source/samples/ucnv/convsamp.cpp index 63922c77363..fb17f500038 100644 --- a/icu4c/source/samples/ucnv/convsamp.cpp +++ b/icu4c/source/samples/ucnv/convsamp.cpp @@ -1,6 +1,6 @@ /************************************************************************** * -* Copyright (C) 2000-2011, International Business Machines +* Copyright (C) 2000-2013, International Business Machines * Corporation and others. All Rights Reserved. * *************************************************************************** @@ -786,8 +786,7 @@ UBool convsample_21_didSubstitute(const char *source) debugCtx1->subContext, flagCtx, debugCtx2, debugCtx2->subCallback); #endif - cloneLen = 1; /* but passing in null so it will clone */ - cloneCnv = ucnv_safeClone(conv, NULL, &cloneLen, &status); + cloneCnv = ucnv_safeClone(conv, NULL, NULL, &status); U_ASSERT(status); diff --git a/icu4c/source/test/cintltst/Makefile.in b/icu4c/source/test/cintltst/Makefile.in index 935e8ffb488..f26c6583ba9 100644 --- a/icu4c/source/test/cintltst/Makefile.in +++ b/icu4c/source/test/cintltst/Makefile.in @@ -37,7 +37,7 @@ CPPFLAGS += -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/ct DEFS += -D'ICU_UNICODE_VERSION="$(UNICODE_VERSION)"' -D'ICU_VERSION="@VERSION@"' -D'ICUDATA_NAME="$(ICUDATA_PLATFORM_NAME)"' -D'U_TOPSRCDIR="$(top_srcdir)/"' -D'U_TOPBUILDDIR="$(BUILDDIR)"' LIBS = $(LIBCTESTFW) $(LIBICUI18N) $(LIBICUTOOLUTIL) $(LIBICUUC) $(DEFAULT_LIBS) $(LIB_M) -OBJECTS = callcoll.o calltest.o colutil.o capitst.o cbiapts.o cbkittst.o \ +OBJECTS = callcoll.o calltest.o capitst.o cbiapts.o cbkittst.o \ ccaltst.o ucnvseltst.o cctest.o ccapitst.o ccolltst.o encoll.o cconvtst.o ccurrtst.o \ cdateintervalformattest.o cdattst.o cdetst.o cdtdptst.o cdtrgtst.o cestst.o cfintst.o \ cformtst.o cfrtst.o cg7coll.o chashtst.o cintltst.o citertst.o cjaptst.o cloctst.o \ diff --git a/icu4c/source/test/cintltst/capitst.c b/icu4c/source/test/cintltst/capitst.c index 11083b93284..90ca87a2bfa 100644 --- a/icu4c/source/test/cintltst/capitst.c +++ b/icu4c/source/test/cintltst/capitst.c @@ -36,7 +36,6 @@ static void TestAttribute(void); static void TestDefault(void); static void TestDefaultKeyword(void); static void TestBengaliSortKey(void); - int TestBufferSize(); /* defined in "colutil.c" */ static char* U_EXPORT2 ucol_sortKeyToString(const UCollator *coll, const uint8_t *sortkey, char *buffer, uint32_t len) { @@ -650,11 +649,6 @@ void TestSafeClone() { const char sampleRuleChars[] = "&Z < CH"; UChar sampleRule[sizeof(sampleRuleChars)]; - if (TestBufferSize()) { - log_err("U_COL_SAFECLONE_BUFFERSIZE should be larger than sizeof(UCollator)\n"); - return; - } - u_uastrcpy(test1, "abCda"); u_uastrcpy(test2, "abcda"); u_uastrcpy(sampleRule, sampleRuleChars); @@ -675,28 +669,30 @@ void TestSafeClone() { /* Check the various error & informational states: */ /* Null status - just returns NULL */ - if (0 != ucol_safeClone(someCollators[0], buffer[0], &bufferSize, 0)) + if (NULL != ucol_safeClone(someCollators[0], buffer[0], &bufferSize, NULL)) { log_err("FAIL: Cloned Collator failed to deal correctly with null status\n"); } /* error status - should return 0 & keep error the same */ err = U_MEMORY_ALLOCATION_ERROR; - if (0 != ucol_safeClone(someCollators[0], buffer[0], &bufferSize, &err) || err != U_MEMORY_ALLOCATION_ERROR) + if (NULL != ucol_safeClone(someCollators[0], buffer[0], &bufferSize, &err) || err != U_MEMORY_ALLOCATION_ERROR) { log_err("FAIL: Cloned Collator failed to deal correctly with incoming error status\n"); } err = U_ZERO_ERROR; - /* Null buffer size pointer - just returns NULL & set error to U_ILLEGAL_ARGUMENT_ERROR*/ - if (0 != ucol_safeClone(someCollators[0], buffer[0], 0, &err) || err != U_ILLEGAL_ARGUMENT_ERROR) + /* Null buffer size pointer is ok */ + if (NULL == (col = ucol_safeClone(someCollators[0], buffer[0], NULL, &err)) || U_FAILURE(err)) { log_err("FAIL: Cloned Collator failed to deal correctly with null bufferSize pointer\n"); } + ucol_close(col); err = U_ZERO_ERROR; /* buffer size pointer is 0 - fill in pbufferSize with a size */ bufferSize = 0; - if (0 != ucol_safeClone(someCollators[0], buffer[0], &bufferSize, &err) || U_FAILURE(err) || bufferSize <= 0) + if (NULL != ucol_safeClone(someCollators[0], buffer[0], &bufferSize, &err) || + U_FAILURE(err) || bufferSize <= 0) { log_err("FAIL: Cloned Collator failed a sizing request ('preflighting')\n"); } @@ -706,14 +702,16 @@ void TestSafeClone() { log_err("FAIL: Pre-calculated buffer size is too small\n"); } /* Verify we can use this run-time calculated size */ - if (0 == (col = ucol_safeClone(someCollators[0], buffer[0], &bufferSize, &err)) || U_FAILURE(err)) + if (NULL == (col = ucol_safeClone(someCollators[0], buffer[0], &bufferSize, &err)) || U_FAILURE(err)) { log_err("FAIL: Collator can't be cloned with run-time size\n"); } if (col) ucol_close(col); /* size one byte too small - should allocate & let us know */ - --bufferSize; - if (0 == (col = ucol_safeClone(someCollators[0], 0, &bufferSize, &err)) || err != U_SAFECLONE_ALLOCATED_WARNING) + if (bufferSize > 1) { + --bufferSize; + } + if (NULL == (col = ucol_safeClone(someCollators[0], 0, &bufferSize, &err)) || err != U_SAFECLONE_ALLOCATED_WARNING) { log_err("FAIL: Cloned Collator failed to deal correctly with too-small buffer size\n"); } @@ -723,7 +721,7 @@ void TestSafeClone() { /* Null buffer pointer - return Collator & set error to U_SAFECLONE_ALLOCATED_ERROR */ - if (0 == (col = ucol_safeClone(someCollators[0], 0, &bufferSize, &err)) || err != U_SAFECLONE_ALLOCATED_WARNING) + if (NULL == (col = ucol_safeClone(someCollators[0], 0, &bufferSize, &err)) || err != U_SAFECLONE_ALLOCATED_WARNING) { log_err("FAIL: Cloned Collator failed to deal correctly with null buffer pointer\n"); } @@ -731,7 +729,7 @@ void TestSafeClone() { err = U_ZERO_ERROR; /* Null Collator - return NULL & set U_ILLEGAL_ARGUMENT_ERROR */ - if (0 != ucol_safeClone(0, buffer[0], &bufferSize, &err) || err != U_ILLEGAL_ARGUMENT_ERROR) + if (NULL != ucol_safeClone(NULL, buffer[0], &bufferSize, &err) || err != U_ILLEGAL_ARGUMENT_ERROR) { log_err("FAIL: Cloned Collator failed to deal correctly with null Collator pointer\n"); } @@ -768,14 +766,9 @@ void TestSafeClone() { bufferSize = U_COL_SAFECLONE_BUFFERSIZE; err = U_ZERO_ERROR; someClonedCollators[idx] = ucol_safeClone(someCollators[idx], buffer[idx], &bufferSize, &err); - if (someClonedCollators[idx] == NULL - || someClonedCollators[idx] < (UCollator *)buffer[idx] - || someClonedCollators[idx] > (UCollator *)(buffer[idx]+(U_COL_SAFECLONE_BUFFERSIZE-1))) - { - /* TODO: The use of U_COL_SAFECLONE_BUFFERSIZE will be deprecated per #9932. - In the meantime, just turn the following former error into a log message. */ - log_verbose("NOTE: Cloned collator did not use provided buffer, index %d, status %s, clone NULL? %d\n", - idx, myErrorName(err), someClonedCollators[idx] == NULL); + if (U_FAILURE(err)) { + log_err("FAIL: Unable to clone collator %d - %s\n", idx, u_errorName(err)); + continue; } if (!ucol_equals(someClonedCollators[idx], someCollators[idx])) { log_err("FAIL: Cloned collator is not equal to original at index = %d.\n", idx); diff --git a/icu4c/source/test/cintltst/cbiapts.c b/icu4c/source/test/cintltst/cbiapts.c index 78755271317..c9080f2d153 100644 --- a/icu4c/source/test/cintltst/cbiapts.c +++ b/icu4c/source/test/cintltst/cbiapts.c @@ -401,28 +401,30 @@ static void TestBreakIteratorSafeClone(void) /* Check the various error & informational states */ /* Null status - just returns NULL */ - if (0 != ubrk_safeClone(someIterators[i], buffer[i], &bufferSize, 0)) + if (NULL != ubrk_safeClone(someIterators[i], buffer[i], &bufferSize, NULL)) { log_err("FAIL: Cloned Iterator failed to deal correctly with null status\n"); } /* error status - should return 0 & keep error the same */ status = U_MEMORY_ALLOCATION_ERROR; - if (0 != ubrk_safeClone(someIterators[i], buffer[i], &bufferSize, &status) || status != U_MEMORY_ALLOCATION_ERROR) + if (NULL != ubrk_safeClone(someIterators[i], buffer[i], &bufferSize, &status) || status != U_MEMORY_ALLOCATION_ERROR) { log_err("FAIL: Cloned Iterator failed to deal correctly with incoming error status\n"); } status = U_ZERO_ERROR; - /* Null buffer size pointer - just returns NULL & set error to U_ILLEGAL_ARGUMENT_ERROR*/ - if (0 != ubrk_safeClone(someIterators[i], buffer[i], 0, &status) || status != U_ILLEGAL_ARGUMENT_ERROR) + /* Null buffer size pointer is ok */ + if (NULL == (brk = ubrk_safeClone(someIterators[i], buffer[i], NULL, &status)) || U_FAILURE(status)) { log_err("FAIL: Cloned Iterator failed to deal correctly with null bufferSize pointer\n"); } + ubrk_close(brk); status = U_ZERO_ERROR; - + /* buffer size pointer is 0 - fill in pbufferSize with a size */ bufferSize = 0; - if (0 != ubrk_safeClone(someIterators[i], buffer[i], &bufferSize, &status) || U_FAILURE(status) || bufferSize <= 0) + if (NULL != ubrk_safeClone(someIterators[i], buffer[i], &bufferSize, &status) || + U_FAILURE(status) || bufferSize <= 0) { log_err("FAIL: Cloned Iterator failed a sizing request ('preflighting')\n"); } @@ -432,15 +434,17 @@ static void TestBreakIteratorSafeClone(void) log_err("FAIL: Pre-calculated buffer size is too small - %d but needed %d\n", U_BRK_SAFECLONE_BUFFERSIZE, bufferSize); } /* Verify we can use this run-time calculated size */ - if (0 == (brk = ubrk_safeClone(someIterators[i], buffer[i], &bufferSize, &status)) || U_FAILURE(status)) + if (NULL == (brk = ubrk_safeClone(someIterators[i], buffer[i], &bufferSize, &status)) || U_FAILURE(status)) { log_err("FAIL: Iterator can't be cloned with run-time size\n"); } if (brk) ubrk_close(brk); /* size one byte too small - should allocate & let us know */ - --bufferSize; - if (0 == (brk = ubrk_safeClone(someIterators[i], 0, &bufferSize, &status)) || status != U_SAFECLONE_ALLOCATED_WARNING) + if (bufferSize > 1) { + --bufferSize; + } + if (NULL == (brk = ubrk_safeClone(someIterators[i], NULL, &bufferSize, &status)) || status != U_SAFECLONE_ALLOCATED_WARNING) { log_err("FAIL: Cloned Iterator failed to deal correctly with too-small buffer size\n"); } @@ -450,7 +454,7 @@ static void TestBreakIteratorSafeClone(void) bufferSize = U_BRK_SAFECLONE_BUFFERSIZE; /* Null buffer pointer - return Iterator & set error to U_SAFECLONE_ALLOCATED_ERROR */ - if (0 == (brk = ubrk_safeClone(someIterators[i], 0, &bufferSize, &status)) || status != U_SAFECLONE_ALLOCATED_WARNING) + if (NULL == (brk = ubrk_safeClone(someIterators[i], NULL, &bufferSize, &status)) || status != U_SAFECLONE_ALLOCATED_WARNING) { log_err("FAIL: Cloned Iterator failed to deal correctly with null buffer pointer\n"); } @@ -461,22 +465,13 @@ static void TestBreakIteratorSafeClone(void) /* Mis-aligned buffer pointer. */ { char stackBuf[U_BRK_SAFECLONE_BUFFERSIZE+sizeof(void *)]; - void *p; - int32_t offset; brk = ubrk_safeClone(someIterators[i], &stackBuf[1], &bufferSize, &status); - if (U_FAILURE(status) || brk == 0) { + if (U_FAILURE(status) || brk == NULL) { log_err("FAIL: Cloned Iterator failed with misaligned buffer pointer\n"); } if (status == U_SAFECLONE_ALLOCATED_WARNING) { - log_err("FAIL: Cloned Iterator allocated when using a mis-aligned buffer.\n"); - } - offset = (int32_t)((char *)&p-(char*)brk); - if (offset < 0) { - offset = -offset; - } - if (offset % sizeof(void *) != 0) { - log_err("FAIL: Cloned Iterator failed to align correctly with misaligned buffer pointer\n"); + log_verbose("Cloned Iterator allocated when using a mis-aligned buffer.\n"); } if (brk) ubrk_close(brk); @@ -484,7 +479,7 @@ static void TestBreakIteratorSafeClone(void) /* Null Iterator - return NULL & set U_ILLEGAL_ARGUMENT_ERROR */ - if (0 != ubrk_safeClone(0, buffer[i], &bufferSize, &status) || status != U_ILLEGAL_ARGUMENT_ERROR) + if (NULL != ubrk_safeClone(NULL, buffer[i], &bufferSize, &status) || status != U_ILLEGAL_ARGUMENT_ERROR) { log_err("FAIL: Cloned Iterator failed to deal correctly with null Iterator pointer\n"); } diff --git a/icu4c/source/test/cintltst/ccapitst.c b/icu4c/source/test/cintltst/ccapitst.c index 7d0725ce4a7..04d1524a3fe 100644 --- a/icu4c/source/test/cintltst/ccapitst.c +++ b/icu4c/source/test/cintltst/ccapitst.c @@ -1712,28 +1712,29 @@ static void TestConvertSafeClone() /* Null status - just returns NULL */ bufferSize = U_CNV_SAFECLONE_BUFFERSIZE; - if (0 != ucnv_safeClone(cnv, buffer[0], &bufferSize, 0)) + if (NULL != ucnv_safeClone(cnv, buffer[0], &bufferSize, NULL)) { log_err("FAIL: Cloned converter failed to deal correctly with null status\n"); } /* error status - should return 0 & keep error the same */ err = U_MEMORY_ALLOCATION_ERROR; - if (0 != ucnv_safeClone(cnv, buffer[0], &bufferSize, &err) || err != U_MEMORY_ALLOCATION_ERROR) + if (NULL != ucnv_safeClone(cnv, buffer[0], &bufferSize, &err) || err != U_MEMORY_ALLOCATION_ERROR) { log_err("FAIL: Cloned converter failed to deal correctly with incoming error status\n"); } err = U_ZERO_ERROR; - /* Null buffer size pointer - just returns NULL & set error to U_ILLEGAL_ARGUMENT_ERROR*/ - if (0 != ucnv_safeClone(cnv, buffer[0], 0, &err) || err != U_ILLEGAL_ARGUMENT_ERROR) + /* Null buffer size pointer is ok */ + if (NULL == (cnv2 = ucnv_safeClone(cnv, buffer[0], NULL, &err)) || U_FAILURE(err)) { log_err("FAIL: Cloned converter failed to deal correctly with null bufferSize pointer\n"); } + ucnv_close(cnv2); err = U_ZERO_ERROR; /* buffer size pointer is 0 - fill in pbufferSize with a size */ bufferSize = 0; - if (0 != ucnv_safeClone(cnv, buffer[0], &bufferSize, &err) || U_FAILURE(err) || bufferSize <= 0) + if (NULL != ucnv_safeClone(cnv, buffer[0], &bufferSize, &err) || U_FAILURE(err) || bufferSize <= 0) { log_err("FAIL: Cloned converter failed a sizing request ('preflighting')\n"); } @@ -1743,7 +1744,7 @@ static void TestConvertSafeClone() log_err("FAIL: Pre-calculated buffer size is too small\n"); } /* Verify we can use this run-time calculated size */ - if (0 == (cnv2 = ucnv_safeClone(cnv, buffer[0], &bufferSize, &err)) || U_FAILURE(err)) + if (NULL == (cnv2 = ucnv_safeClone(cnv, buffer[0], &bufferSize, &err)) || U_FAILURE(err)) { log_err("FAIL: Converter can't be cloned with run-time size\n"); } @@ -1753,7 +1754,7 @@ static void TestConvertSafeClone() /* size one byte too small - should allocate & let us know */ --bufferSize; - if (0 == (cnv2 = ucnv_safeClone(cnv, 0, &bufferSize, &err)) || err != U_SAFECLONE_ALLOCATED_WARNING) + if (NULL == (cnv2 = ucnv_safeClone(cnv, NULL, &bufferSize, &err)) || err != U_SAFECLONE_ALLOCATED_WARNING) { log_err("FAIL: Cloned converter failed to deal correctly with too-small buffer size\n"); } @@ -1765,7 +1766,7 @@ static void TestConvertSafeClone() bufferSize = U_CNV_SAFECLONE_BUFFERSIZE; /* Null buffer pointer - return converter & set error to U_SAFECLONE_ALLOCATED_ERROR */ - if (0 == (cnv2 = ucnv_safeClone(cnv, 0, &bufferSize, &err)) || err != U_SAFECLONE_ALLOCATED_WARNING) + if (NULL == (cnv2 = ucnv_safeClone(cnv, NULL, &bufferSize, &err)) || err != U_SAFECLONE_ALLOCATED_WARNING) { log_err("FAIL: Cloned converter failed to deal correctly with null buffer pointer\n"); } @@ -1776,7 +1777,7 @@ static void TestConvertSafeClone() err = U_ZERO_ERROR; /* Null converter - return NULL & set U_ILLEGAL_ARGUMENT_ERROR */ - if (0 != ucnv_safeClone(0, buffer[0], &bufferSize, &err) || err != U_ILLEGAL_ARGUMENT_ERROR) + if (NULL != ucnv_safeClone(NULL, buffer[0], &bufferSize, &err) || err != U_ILLEGAL_ARGUMENT_ERROR) { log_err("FAIL: Cloned converter failed to deal correctly with null converter pointer\n"); } diff --git a/icu4c/source/test/cintltst/cintltst.vcxproj b/icu4c/source/test/cintltst/cintltst.vcxproj index b5364112277..17529b6200a 100644 --- a/icu4c/source/test/cintltst/cintltst.vcxproj +++ b/icu4c/source/test/cintltst/cintltst.vcxproj @@ -242,7 +242,6 @@ - diff --git a/icu4c/source/test/cintltst/cintltst.vcxproj.filters b/icu4c/source/test/cintltst/cintltst.vcxproj.filters index ff6b1614a13..c12ab5a432f 100644 --- a/icu4c/source/test/cintltst/cintltst.vcxproj.filters +++ b/icu4c/source/test/cintltst/cintltst.vcxproj.filters @@ -99,9 +99,6 @@ collation - - collation - collation diff --git a/icu4c/source/test/cintltst/cmsccoll.c b/icu4c/source/test/cintltst/cmsccoll.c index 4145eaae148..b47472806b2 100644 --- a/icu4c/source/test/cintltst/cmsccoll.c +++ b/icu4c/source/test/cintltst/cmsccoll.c @@ -4071,10 +4071,10 @@ static void TestSettings(void) { static int32_t TestEqualsForCollator(const char* locName, UCollator *source, UCollator *target) { UErrorCode status = U_ZERO_ERROR; int32_t errorNo = 0; - /*const UChar *sourceRules = NULL;*/ - /*int32_t sourceRulesLen = 0;*/ + const UChar *sourceRules = NULL; + int32_t sourceRulesLen = 0; + UParseError parseError; UColAttributeValue french = UCOL_OFF; - int32_t cloneSize = 0; if(!ucol_equals(source, target)) { log_err("Same collators, different address not equal\n"); @@ -4082,11 +4082,7 @@ static int32_t TestEqualsForCollator(const char* locName, UCollator *source, UCo } ucol_close(target); if(uprv_strcmp(ucol_getLocaleByType(source, ULOC_REQUESTED_LOCALE, &status), ucol_getLocaleByType(source, ULOC_ACTUAL_LOCALE, &status)) == 0) { - /* currently, safeClone is implemented through getRules/openRules - * so it is the same as the test below - I will comment that test out. - */ - /* real thing */ - target = ucol_safeClone(source, NULL, &cloneSize, &status); + target = ucol_safeClone(source, NULL, NULL, &status); if(U_FAILURE(status)) { log_err("Error creating clone\n"); errorNo++; @@ -4112,21 +4108,19 @@ static int32_t TestEqualsForCollator(const char* locName, UCollator *source, UCo errorNo++; } ucol_close(target); - /* commented out since safeClone uses exactly the same technique */ - /* + sourceRules = ucol_getRules(source, &sourceRulesLen); target = ucol_openRules(sourceRules, sourceRulesLen, UCOL_DEFAULT, UCOL_DEFAULT, &parseError, &status); if(U_FAILURE(status)) { - log_err("Error instantiating target from rules\n"); - errorNo++; - return errorNo; + log_err("Error instantiating target from rules - %s\n", u_errorName(status)); + errorNo++; + return errorNo; } if(!ucol_equals(source, target)) { - log_err("Collator different from collator that was created from the same rules\n"); - errorNo++; + log_err("Collator different from collator that was created from the same rules\n"); + errorNo++; } ucol_close(target); - */ } return errorNo; } @@ -6367,7 +6361,6 @@ static void TestReorderingAcrossCloning(void) UCollator *myCollation; int32_t reorderCodes[3] = {USCRIPT_GREEK, USCRIPT_HAN, UCOL_REORDER_CODE_PUNCTUATION}; UCollator *clonedCollation; - int32_t bufferSize; int32_t retrievedReorderCodesLength; int32_t retrievedReorderCodes[10]; int loopIndex; @@ -6390,7 +6383,7 @@ static void TestReorderingAcrossCloning(void) } /* clone the collator */ - clonedCollation = ucol_safeClone(myCollation, NULL, &bufferSize, &status); + clonedCollation = ucol_safeClone(myCollation, NULL, NULL, &status); if (U_FAILURE(status)) { log_err_status(status, "ERROR: cloning collator: %s\n", myErrorName(status)); return; diff --git a/icu4c/source/test/cintltst/colutil.c b/icu4c/source/test/cintltst/colutil.c deleted file mode 100644 index 8e9f3609118..00000000000 --- a/icu4c/source/test/cintltst/colutil.c +++ /dev/null @@ -1,17 +0,0 @@ -/******************************************************************** - * COPYRIGHT: - * Copyright (c) 1997-2003, International Business Machines Corporation and - * others. All Rights Reserved. - ********************************************************************/ - -#include "ucol_imp.h" - -#if !UCONFIG_NO_COLLATION - -int TestBufferSize(void); /* keep gcc happy */ - -int TestBufferSize(void) -{ - return (U_COL_SAFECLONE_BUFFERSIZE < sizeof(UCollator)); -} -#endif diff --git a/icu4c/source/test/intltest/strcase.cpp b/icu4c/source/test/intltest/strcase.cpp index 75fc74047da..a35d5532782 100644 --- a/icu4c/source/test/intltest/strcase.cpp +++ b/icu4c/source/test/intltest/strcase.cpp @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 2002-2012, International Business Machines +* Copyright (C) 2002-2013, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -397,8 +397,7 @@ StringCaseTest::TestCasingImpl(const UnicodeString &input, #if !UCONFIG_NO_BREAK_ITERATION if(iter!=NULL) { // Clone the break iterator so that the UCaseMap can safely adopt it. - int32_t size=1; // Not 0 because that only gives preflighting. - UBreakIterator *clone=ubrk_safeClone((UBreakIterator *)iter, NULL, &size, errorCode); + UBreakIterator *clone=ubrk_safeClone((UBreakIterator *)iter, NULL, NULL, errorCode); ucasemap_setBreakIterator(csm.getAlias(), clone, errorCode); } #endif