Overview
Comment: | Make use of the recent change to -[initWithCString:encoding:length:]. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
581164864f488f97bce6249a3c65f208 |
User & Date: | js on 2009-11-02 14:47:30 |
Other Links: | manifest | tags |
Context
2009-11-03
| ||
14:15 | Update .xcodeproj. check-in: 52bda71915 user: js tags: trunk | |
2009-11-02
| ||
14:47 | Make use of the recent change to -[initWithCString:encoding:length:]. check-in: 581164864f user: js tags: trunk | |
11:15 | Add #ifdef construct to allow building universal binaries on OS X. check-in: 3f9c30abc0 user: js tags: trunk | |
Changes
Modified src/OFHashes.m from [11feb3bb82] to [322293e92b].
︙ | ︙ | |||
430 431 432 433 434 435 436 | @implementation OFString (OFHashing) - (OFString*)md5Hash { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFMD5Hash *hash = [OFMD5Hash md5Hash]; uint8_t *digest; | | < | > | < | > | 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | @implementation OFString (OFHashing) - (OFString*)md5Hash { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFMD5Hash *hash = [OFMD5Hash md5Hash]; uint8_t *digest; char ret_c[32]; size_t i; [hash updateWithBuffer: string ofSize: length]; digest = [hash digest]; for (i = 0; i < 16; i++) { uint8_t high, low; high = digest[i] >> 4; low = digest[i] & 0x0F; ret_c[i * 2] = (high > 9 ? high - 10 + 'a' : high + '0'); ret_c[i * 2 + 1] = (low > 9 ? low - 10 + 'a' : low + '0'); } [pool release]; return [OFString stringWithCString: ret_c length: 32]; } - (OFString*)sha1Hash { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFMD5Hash *hash = [OFSHA1Hash sha1Hash]; uint8_t *digest; char ret_c[40]; size_t i; [hash updateWithBuffer: string ofSize: length]; digest = [hash digest]; for (i = 0; i < 20; i++) { uint8_t high, low; high = digest[i] >> 4; low = digest[i] & 0x0F; ret_c[i * 2] = (high > 9 ? high - 10 + 'a' : high + '0'); ret_c[i * 2 + 1] = (low > 9 ? low - 10 + 'a' : low + '0'); } [pool release]; return [OFString stringWithCString: ret_c length: 40]; } @end |
Modified src/OFStream.m from [ca6dc099de] to [d18abfb3eb].
︙ | ︙ | |||
126 127 128 129 130 131 132 | } /* Look if there's a newline or \0 */ for (i = 0; i < len; i++) { if (OF_UNLIKELY(tmp[i] == '\n' || tmp[i] == '\0')) { @try { ret_c = [self | | < < | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | } /* Look if there's a newline or \0 */ for (i = 0; i < len; i++) { if (OF_UNLIKELY(tmp[i] == '\n' || tmp[i] == '\0')) { @try { ret_c = [self allocMemoryWithSize: cache_len + i]; } @catch (OFException *e) { [self freeMemory: tmp]; @throw e; } if (cache != NULL) memcpy(ret_c, cache, cache_len); memcpy(ret_c + cache_len, tmp, i); if (i < len) { @try { tmp2 = [self allocMemoryWithSize: len - i - 1]; } @catch (OFException *e) { |
︙ | ︙ | |||
164 165 166 167 168 169 170 | cache_len = 0; } [self freeMemory: tmp]; @try { ret = [OFString stringWithCString: ret_c | | > | 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | cache_len = 0; } [self freeMemory: tmp]; @try { ret = [OFString stringWithCString: ret_c encoding: encoding length: cache_len + i]; } @finally { [self freeMemory: ret_c]; } return ret; } } |
︙ | ︙ |
Modified src/OFURLEncoding.m from [fb4ac5dc95] to [00bfbc007f].
︙ | ︙ | |||
51 52 53 54 55 56 57 | low = *s & 0x0F; ret_c[i++] = '%'; ret_c[i++] = (high > 9 ? high - 10 + 'A' : high + '0'); ret_c[i++] = (low > 9 ? low - 10 + 'A' : low + '0'); } } | < | > | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | low = *s & 0x0F; ret_c[i++] = '%'; ret_c[i++] = (high > 9 ? high - 10 + 'A' : high + '0'); ret_c[i++] = (low > 9 ? low - 10 + 'A' : low + '0'); } } @try { ret = [OFString stringWithCString: ret_c length: i]; } @finally { free(ret_c); } return ret; } |
︙ | ︙ | |||
121 122 123 124 125 126 127 | } @try { ret = [OFString stringWithCString: ret_c]; } @finally { free(ret_c); } | < | 121 122 123 124 125 126 127 128 129 130 | } @try { ret = [OFString stringWithCString: ret_c]; } @finally { free(ret_c); } return ret; } @end |
Modified src/OFXMLElement.m from [5f67a0c8ca] to [d918183a6a].
︙ | ︙ | |||
122 123 124 125 126 127 128 | { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; char *str_c; size_t len, i, j, attrs_count; OFXMLAttribute **attrs_carray; OFString *ret, *tmp; | | | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; char *str_c; size_t len, i, j, attrs_count; OFXMLAttribute **attrs_carray; OFString *ret, *tmp; len = [name cStringLength] + 3; str_c = [self allocMemoryWithSize: len]; /* Start of tag */ *str_c = '<'; memcpy(str_c + 1, [name cString], [name cStringLength]); i = [name cStringLength] + 1; |
︙ | ︙ | |||
200 201 202 203 204 205 206 | str_c[i++] = '/'; memcpy(str_c + i, [name cString], [name cStringLength]); i += [name cStringLength]; } else str_c[i++] = '/'; str_c[i++] = '>'; | < | > < | 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | str_c[i++] = '/'; memcpy(str_c + i, [name cString], [name cStringLength]); i += [name cStringLength]; } else str_c[i++] = '/'; str_c[i++] = '>'; assert(i == len); [pool release]; @try { ret = [OFString stringWithCString: str_c length: len]; } @finally { [self freeMemory: str_c]; } return ret; } - addAttribute: (OFXMLAttribute*)attr { if (attrs == nil) attrs = [[OFMutableArray alloc] init]; |
︙ | ︙ | |||
276 277 278 279 280 281 282 | { char *str_c, *append, *tmp; size_t len, append_len; size_t i, j; OFString *ret; j = 0; | | | | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | { char *str_c, *append, *tmp; size_t len, append_len; size_t i, j; OFString *ret; j = 0; len = length; /* * We can't use allocMemoryWithSize: here as it might be a @"" literal */ if ((str_c = malloc(len)) == NULL) @throw [OFOutOfMemoryException newWithClass: isa size: len]; for (i = 0; i < length; i++) { switch (string[i]) { case '<': append = "<"; |
︙ | ︙ | |||
328 329 330 331 332 333 334 | memcpy(str_c + j, append, append_len); j += append_len; } else str_c[j++] = string[i]; } | < | > < | 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | memcpy(str_c + j, append, append_len); j += append_len; } else str_c[j++] = string[i]; } assert(j == len); @try { ret = [OFString stringWithCString: str_c length: len]; } @finally { free(str_c); } return ret; } @end |