Differences From Artifact [3a4097c573]:
- File src/OFString+URLEncoding.m — part of check-in [2ca121fd19] at 2014-07-06 11:04:40 on branch trunk — OFString+URLEncoding.m: Better RFC 1738 compliance (user: js, size: 3477) [annotate] [blame] [check-ins using]
To Artifact [89405889ad]:
- File
src/OFString+URLEncoding.m
— part of check-in
[b5c8b62533]
at
2014-07-06 11:04:57
on branch trunk
— OFString+*.m: Add a few missing autorelease pools
Those were only a problem if the user created its own OFString subclass,
as calls to -[UTF8String] could then create a new, autoreleased C
string. As OFString_UTF8 simply returns the internal C string, this
hasn't been a problem when not subclassing OFString. (user: js, size: 3627) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
27 28 29 30 31 32 33 34 35 36 37 38 39 40 | /* Reference for static linking */ int _OFString_URLEncoding_reference; @implementation OFString (URLEncoding) - (OFString*)stringByURLEncoding { const char *string = [self UTF8String]; char *retCString; size_t i; OFString *ret; /* * Worst case: 3 times longer than before. | > | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | /* Reference for static linking */ int _OFString_URLEncoding_reference; @implementation OFString (URLEncoding) - (OFString*)stringByURLEncoding { void *pool = objc_autoreleasePoolPush(); const char *string = [self UTF8String]; char *retCString; size_t i; OFString *ret; /* * Worst case: 3 times longer than before. |
︙ | ︙ | |||
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | retCString[i++] = (high > 9 ? high - 10 + 'A' : high + '0'); retCString[i++] = (low > 9 ? low - 10 + 'A' : low + '0'); } } @try { ret = [OFString stringWithUTF8String: retCString length: i]; } @finally { free(retCString); } return ret; } - (OFString*)stringByURLDecoding { OFString *ret; const char *string = [self UTF8String]; char *retCString; char byte = 0; int state = 0; size_t i; | > > > | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | retCString[i++] = (high > 9 ? high - 10 + 'A' : high + '0'); retCString[i++] = (low > 9 ? low - 10 + 'A' : low + '0'); } } objc_autoreleasePoolPop(pool); @try { ret = [OFString stringWithUTF8String: retCString length: i]; } @finally { free(retCString); } return ret; } - (OFString*)stringByURLDecoding { void *pool = objc_autoreleasePoolPush(); OFString *ret; const char *string = [self UTF8String]; char *retCString; char byte = 0; int state = 0; size_t i; |
︙ | ︙ | |||
124 125 126 127 128 129 130 131 132 133 134 135 136 137 | byte = 0; } break; } } retCString[i] = '\0'; if (state != 0) { free(retCString); @throw [OFInvalidFormatException exception]; } @try { | > > | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | byte = 0; } break; } } retCString[i] = '\0'; objc_autoreleasePoolPop(pool); if (state != 0) { free(retCString); @throw [OFInvalidFormatException exception]; } @try { |
︙ | ︙ |