Differences From Artifact [5faa6d539b]:
- File
src/OFString_UTF8.m
— part of check-in
[f7576a66ce]
at
2012-06-06 13:47:52
on branch trunk
— Slightly change the memory management API.
Also fix a bug where OFBigDataArray would waste memory. (user: js, size: 25150) [annotate] [blame] [check-ins using] [more...]
To Artifact [65dd22d751]:
- File src/OFString_UTF8.m — part of check-in [11d3d69a22] at 2012-06-10 13:28:05 on branch trunk — More API improvements. (user: js, size: 25149) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
177 178 179 180 181 182 183 | if (bytes == 0) @throw [OFInvalidEncodingException exceptionWithClass: isa]; s->cStringLength += bytes - 1; s->cString = [self resizeMemory: s->cString | | | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | if (bytes == 0) @throw [OFInvalidEncodingException exceptionWithClass: isa]; s->cStringLength += bytes - 1; s->cString = [self resizeMemory: s->cString size: s->cStringLength + 1]; memcpy(s->cString + j, buffer, bytes); j += bytes; } s->cString[s->cStringLength] = 0; |
︙ | ︙ | |||
226 227 228 229 230 231 232 | if (characterBytes == 0) @throw [OFInvalidEncodingException exceptionWithClass: isa]; s->cStringLength += characterBytes - 1; s->cString = [self resizeMemory: s->cString | | | 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | if (characterBytes == 0) @throw [OFInvalidEncodingException exceptionWithClass: isa]; s->cStringLength += characterBytes - 1; s->cString = [self resizeMemory: s->cString size: s->cStringLength + 1]; memcpy(s->cString + j, buffer, characterBytes); j += characterBytes; } s->cString[s->cStringLength] = 0; } @catch (id e) { |
︙ | ︙ | |||
338 339 340 341 342 343 344 | } } s->cString[j] = '\0'; @try { s->cString = [self resizeMemory: s->cString | | | 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | } } s->cString[j] = '\0'; @try { s->cString = [self resizeMemory: s->cString size: s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't care, as we only tried to make it smaller */ } } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ | |||
446 447 448 449 450 451 452 | } } s->cString[j] = '\0'; @try { s->cString = [self resizeMemory: s->cString | | | 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | } } s->cString[j] = '\0'; @try { s->cString = [self resizeMemory: s->cString size: s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't care, as we only tried to make it smaller */ } } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ | |||
1090 1091 1092 1093 1094 1095 1096 | - (const of_unichar_t*)unicodeString { OFObject *object = [[[OFObject alloc] init] autorelease]; of_unichar_t *ret; size_t i, j; | | | | 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 | - (const of_unichar_t*)unicodeString { OFObject *object = [[[OFObject alloc] init] autorelease]; of_unichar_t *ret; size_t i, j; ret = [object allocMemoryWithSize: sizeof(of_unichar_t) count: s->length + 1]; i = 0; j = 0; while (i < s->cStringLength) { of_unichar_t c; size_t cLen; |
︙ | ︙ |