@@ -32,28 +32,27 @@ - (OFString *)stringByURLEncodingWithAllowedCharacters: (OFCharacterSet *)allowedCharacters { OFMutableString *ret = [OFMutableString string]; void *pool = objc_autoreleasePoolPush(); - const of_unichar_t *characters = self.characters; + const OFUnichar *characters = self.characters; size_t length = self.length; - bool (*characterIsMember)(id, SEL, of_unichar_t) = - (bool (*)(id, SEL, of_unichar_t))[allowedCharacters + bool (*characterIsMember)(id, SEL, OFUnichar) = + (bool (*)(id, SEL, OFUnichar))[allowedCharacters methodForSelector: @selector(characterIsMember:)]; for (size_t i = 0; i < length; i++) { - of_unichar_t c = characters[i]; + OFUnichar c = characters[i]; if (characterIsMember(allowedCharacters, @selector(characterIsMember:), c)) - [ret appendCharacters: &c - length: 1]; + [ret appendCharacters: &c length: 1]; else { char buffer[4]; size_t bufferLen; - if ((bufferLen = of_string_utf8_encode(c, buffer)) == 0) + if ((bufferLen = OFUTF8StringEncode(c, buffer)) == 0) @throw [OFInvalidEncodingException exception]; for (size_t j = 0; j < bufferLen; j++) { unsigned char byte = buffer[j]; unsigned char high = byte >> 4; @@ -64,12 +63,11 @@ escaped[1] = (high > 9 ? high - 10 + 'A' : high + '0'); escaped[2] = (low > 9 ? low - 10 + 'A' : low + '0'); - [ret appendUTF8String: escaped - length: 3]; + [ret appendUTF8String: escaped length: 3]; } } } objc_autoreleasePoolPop(pool); @@ -85,11 +83,11 @@ char *retCString; char byte = 0; int state = 0; size_t i = 0; - retCString = of_alloc(length + 1, 1); + retCString = OFAllocMemory(length + 1, 1); while (length--) { char c = *string++; switch (state) { @@ -108,11 +106,11 @@ else if (c >= 'A' && c <= 'F') byte += (c - 'A' + 10) << shift; else if (c >= 'a' && c <= 'f') byte += (c - 'a' + 10) << shift; else { - free(retCString); + OFFreeMemory(retCString); @throw [OFInvalidFormatException exception]; } if (++state == 3) { retCString[i++] = byte; @@ -126,25 +124,25 @@ retCString[i] = '\0'; objc_autoreleasePoolPop(pool); if (state != 0) { - free(retCString); + OFFreeMemory(retCString); @throw [OFInvalidFormatException exception]; } @try { - retCString = of_realloc(retCString, 1, i + 1); + retCString = OFResizeMemory(retCString, 1, i + 1); } @catch (OFOutOfMemoryException *e) { /* We don't care if it fails, as we only made it smaller. */ } @try { return [OFString stringWithUTF8StringNoCopy: retCString length: i freeWhenDone: true]; } @catch (id e) { - free(retCString); + OFFreeMemory(retCString); @throw e; } } @end