Logo Search packages:      
Sourcecode: icu version File versions  Download package

U_STABLE UBreakIterator* U_EXPORT2 ubrk_safeClone ( const UBreakIterator bi,
void *  stackBuffer,
int32_t *  pBufferSize,
UErrorCode status 
)

Thread safe cloning operation

Parameters:
bi iterator to be cloned
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_BRK_SAFECLONE_BUFFERSIZE. This will probably be enough to avoid memory allocations.
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.
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.
Returns:
pointer to the new clone ICU 2.0

Definition at line 124 of file ubrk.cpp.

References NULL, U_FAILURE, U_ILLEGAL_ARGUMENT_ERROR, U_SAFECLONE_ALLOCATED_WARNING, and U_ZERO_ERROR.

{
    if (status == NULL || U_FAILURE(*status)){
        return 0;
    }
    if (!pBufferSize || !bi){
       *status = U_ILLEGAL_ARGUMENT_ERROR;
        return 0;
    }
    // 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;
    }
    return (UBreakIterator *)(((BreakIterator*)bi)->
        createBufferClone(stackBuffer, *pBufferSize, *status));
}


Generated by  Doxygen 1.6.0   Back to index