/*
*******************************************************************************
*
- * Copyright (C) 2003, International Business Machines
+ * Copyright (C) 2003-2010, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
U16_NEXT(buffer, bufIndex, bufLen, ch);
if(unassigned.contains(ch)){
status = U_IDNA_UNASSIGNED_ERROR;
- rsource.releaseBuffer();
return 0;
}
}
return 0;
}
- UChar b1Stack[MAX_BUFFER_SIZE];
- UChar *b1 = b1Stack;
- int32_t b1Len,b1Capacity = MAX_BUFFER_SIZE;
+ UnicodeString b1String;
+ UChar *b1 = b1String.getBuffer(MAX_BUFFER_SIZE);
+ int32_t b1Len;
int32_t b1Index = 0;
UCharDirection direction=U_CHAR_DIRECTION_COUNT, firstCharDir=U_CHAR_DIRECTION_COUNT;
UBool leftToRight=FALSE, rightToLeft=FALSE;
- b1Len = map(src,srcLength, b1, b1Capacity,allowUnassigned,parseError, status);
+ b1Len = map(src, srcLength, b1, b1String.getCapacity(), allowUnassigned, parseError, status);
+ b1String.releaseBuffer(b1Len);
if(status == U_BUFFER_OVERFLOW_ERROR){
// redo processing of string
/* we do not have enough room so grow the buffer*/
- if(!u_growBufferFromStatic(b1Stack,&b1,&b1Capacity,b1Len,0)){
- status = U_MEMORY_ALLOCATION_ERROR;
- goto CLEANUP;
- }
-
+ b1 = b1String.getBuffer(b1Len);
status = U_ZERO_ERROR; // reset error
-
- b1Len = map(src,srcLength, b1, b1Len,allowUnassigned, parseError, status);
-
+ b1Len = map(src, srcLength, b1, b1String.getCapacity(), allowUnassigned, parseError, status);
+ b1String.releaseBuffer(b1Len);
}
if(U_FAILURE(status)){
+ b1Len = 0;
goto CLEANUP;
}
if(prohibited.contains(ch) && ch!=0x0020){
status = U_IDNA_PROHIBITED_ERROR;
+ b1Len = 0;
goto CLEANUP;
}
// satisfy 2
if( leftToRight == TRUE && rightToLeft == TRUE){
status = U_IDNA_CHECK_BIDI_ERROR;
+ b1Len = 0;
goto CLEANUP;
}
}
CLEANUP:
- if(b1!=b1Stack){
- uprv_free(b1);
- }
-
return u_terminateUChars(dest, destCapacity, b1Len, &status);
}