1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* 2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru******************************************************************************* 3ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius* Copyright (C) 1998-2012, International Business Machines 5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Corporation and others. All Rights Reserved. 6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru******************************************************************************* 8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* File ustr.c 10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Modification History: 12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Date Name Description 14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 05/28/99 stephen Creation. 15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru******************************************************************************* 16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/ 17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "ustr.h" 19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "cmemory.h" 20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "cstring.h" 21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/ustring.h" 22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/putil.h" 2354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius#include "unicode/utf16.h" 24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* Protos */ 26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void ustr_resize(struct UString *s, int32_t len, UErrorCode *status); 27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* Macros */ 29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define ALLOCATION(minSize) (minSize < 0x80 ? 0x80 : (2 * minSize + 0x80) & ~(0x80 - 1)) 30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 31103e9ffba2cba345d0078eb8b8db33249f81840aCraig CorneliusU_CFUNC void 32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruustr_init(struct UString *s) 33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{ 34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru s->fChars = 0; 35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru s->fLength = s->fCapacity = 0; 36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 38103e9ffba2cba345d0078eb8b8db33249f81840aCraig CorneliusU_CFUNC void 39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruustr_initChars(struct UString *s, const char* source, int32_t length, UErrorCode *status) 40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{ 41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int i = 0; 42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if (U_FAILURE(*status)) return; 43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru s->fChars = 0; 44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru s->fLength = s->fCapacity = 0; 45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if (length == -1) { 46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru length = (int32_t)uprv_strlen(source); 47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(s->fCapacity < length) { 49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ustr_resize(s, ALLOCATION(length), status); 50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(U_FAILURE(*status)) return; 51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru for (; i < length; i++) 53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru { 54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UChar charToAppend; 55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru u_charsToUChars(source+i, &charToAppend, 1); 56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ustr_ucat(s, charToAppend, status); 57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* 58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if U_CHARSET_FAMILY==U_ASCII_FAMILY 59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ustr_ucat(s, (UChar)(uint8_t)(source[i]), status); 60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY 61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ustr_ucat(s, (UChar)asciiFromEbcdic[(uint8_t)(*cs++)], status); 62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#else 63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# error U_CHARSET_FAMILY is not valid 64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif 65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 69103e9ffba2cba345d0078eb8b8db33249f81840aCraig CorneliusU_CFUNC void 70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruustr_deinit(struct UString *s) 71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{ 7285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho if (s) { 7385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho uprv_free(s->fChars); 7485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho s->fChars = 0; 7585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho s->fLength = s->fCapacity = 0; 7685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho } 77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 79103e9ffba2cba345d0078eb8b8db33249f81840aCraig CorneliusU_CFUNC void 80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruustr_cpy(struct UString *dst, 81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const struct UString *src, 82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode *status) 83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{ 84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(U_FAILURE(*status) || dst == src) 85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return; 86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(dst->fCapacity < src->fLength) { 88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ustr_resize(dst, ALLOCATION(src->fLength), status); 89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(U_FAILURE(*status)) 90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return; 91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(src->fChars == NULL || dst->fChars == NULL){ 93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return; 94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru uprv_memcpy(dst->fChars, src->fChars, sizeof(UChar) * src->fLength); 96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru dst->fLength = src->fLength; 97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru dst->fChars[dst->fLength] = 0x0000; 98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 100103e9ffba2cba345d0078eb8b8db33249f81840aCraig CorneliusU_CFUNC void 101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruustr_setlen(struct UString *s, 102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t len, 103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode *status) 104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{ 105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(U_FAILURE(*status)) 106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return; 107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(s->fCapacity < (len + 1)) { 109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ustr_resize(s, ALLOCATION(len), status); 110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(U_FAILURE(*status)) 111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return; 112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru s->fLength = len; 115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru s->fChars[len] = 0x0000; 116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 118103e9ffba2cba345d0078eb8b8db33249f81840aCraig CorneliusU_CFUNC void 119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruustr_cat(struct UString *dst, 120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const struct UString *src, 121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode *status) 122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{ 123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ustr_ncat(dst, src, src->fLength, status); 124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 126103e9ffba2cba345d0078eb8b8db33249f81840aCraig CorneliusU_CFUNC void 127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruustr_ncat(struct UString *dst, 128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const struct UString *src, 129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t n, 130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode *status) 131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{ 132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(U_FAILURE(*status) || dst == src) 133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return; 134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(dst->fCapacity < (dst->fLength + n)) { 136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ustr_resize(dst, ALLOCATION(dst->fLength + n), status); 137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(U_FAILURE(*status)) 138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return; 139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru uprv_memcpy(dst->fChars + dst->fLength, src->fChars, 142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru sizeof(UChar) * n); 143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru dst->fLength += src->fLength; 144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru dst->fChars[dst->fLength] = 0x0000; 145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 147103e9ffba2cba345d0078eb8b8db33249f81840aCraig CorneliusU_CFUNC void 148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruustr_ucat(struct UString *dst, 149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UChar c, 150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode *status) 151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{ 152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(U_FAILURE(*status)) 153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return; 154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(dst->fCapacity < (dst->fLength + 1)) { 156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ustr_resize(dst, ALLOCATION(dst->fLength + 1), status); 157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(U_FAILURE(*status)) 158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return; 159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru uprv_memcpy(dst->fChars + dst->fLength, &c, 162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru sizeof(UChar) * 1); 163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru dst->fLength += 1; 164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru dst->fChars[dst->fLength] = 0x0000; 165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 166103e9ffba2cba345d0078eb8b8db33249f81840aCraig CorneliusU_CFUNC void 167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruustr_u32cat(struct UString *dst, UChar32 c, UErrorCode *status){ 168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(c > 0x10FFFF){ 169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *status = U_ILLEGAL_CHAR_FOUND; 170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return; 171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(c >0xFFFF){ 173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ustr_ucat(dst, U16_LEAD(c), status); 174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ustr_ucat(dst, U16_TRAIL(c), status); 175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru }else{ 176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ustr_ucat(dst, (UChar) c, status); 177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 179103e9ffba2cba345d0078eb8b8db33249f81840aCraig CorneliusU_CFUNC void 180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruustr_uscat(struct UString *dst, 181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UChar* src,int len, 182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode *status) 183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{ 184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(U_FAILURE(*status)) 185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return; 186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(dst->fCapacity < (dst->fLength + len)) { 188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ustr_resize(dst, ALLOCATION(dst->fLength + len), status); 189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(U_FAILURE(*status)) 190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return; 191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru uprv_memcpy(dst->fChars + dst->fLength, src, 194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru sizeof(UChar) * len); 195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru dst->fLength += len; 196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru dst->fChars[dst->fLength] = 0x0000; 197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* Destroys data in the string */ 200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void 201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruustr_resize(struct UString *s, 202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t len, 203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode *status) 204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{ 205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(U_FAILURE(*status)) 206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return; 207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* +1 for trailing 0x0000 */ 209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru s->fChars = (UChar*) uprv_realloc(s->fChars, sizeof(UChar) * (len + 1)); 210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(s->fChars == 0) { 211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *status = U_MEMORY_ALLOCATION_ERROR; 212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru s->fLength = s->fCapacity = 0; 213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return; 214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru s->fCapacity = len; 217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 218