@@ -103,12 +103,11 @@ return; } unicodeLen = self.length; - unicodeString = [self allocMemoryWithSize: sizeof(of_unichar_t) - count: unicodeLen]; + unicodeString = of_malloc(unicodeLen, sizeof(of_unichar_t)); i = j = 0; newCStringLength = 0; while (i < _s->cStringLength) { @@ -127,11 +126,11 @@ cLen = of_string_utf8_decode(_s->cString + i, _s->cStringLength - i, &c); if (cLen <= 0 || c > 0x10FFFF) { - [self freeMemory: unicodeString]; + free(unicodeString); @throw [OFInvalidEncodingException exception]; } isStart = of_ascii_isspace(c); @@ -150,21 +149,21 @@ else if (c < 0x10000) newCStringLength += 3; else if (c < 0x110000) newCStringLength += 4; else { - [self freeMemory: unicodeString]; + free(unicodeString); @throw [OFInvalidEncodingException exception]; } i += cLen; } @try { newCString = [self allocMemoryWithSize: newCStringLength + 1]; } @catch (id e) { - [self freeMemory: unicodeString]; + free(unicodeString); @throw e; } j = 0; @@ -171,20 +170,20 @@ for (i = 0; i < unicodeLen; i++) { size_t d; if ((d = of_string_utf8_encode(unicodeString[i], newCString + j)) == 0) { - [self freeMemory: unicodeString]; + free(unicodeString); [self freeMemory: newCString]; @throw [OFInvalidEncodingException exception]; } j += d; } assert(j == newCStringLength); newCString[j] = 0; - [self freeMemory: unicodeString]; + free(unicodeString); [self freeMemory: _s->cString]; _s->hashed = false; _s->cString = newCString; _s->cStringLength = newCStringLength; @@ -383,13 +382,12 @@ } - (void)appendCharacters: (const of_unichar_t *)characters length: (size_t)length { - char *tmp; + char *tmp = of_malloc((length * 4) + 1, 1); - tmp = [self allocMemoryWithSize: (length * 4) + 1]; @try { size_t j = 0; bool isUTF8 = false; for (size_t i = 0; i < length; i++) { @@ -416,11 +414,11 @@ _s->length += length; if (isUTF8) _s->isUTF8 = true; } @finally { - [self freeMemory: tmp]; + free(tmp); } } - (void)appendFormat: (OFConstantString *)format arguments: (va_list)arguments