@@ -833,11 +833,11 @@ freeWhenDone: (bool)freeWhenDone { id ret = [self initWithUTF8String: UTF8String]; if (freeWhenDone) - free(UTF8String); + OFFreeMemory(UTF8String); return ret; } - (instancetype)initWithUTF8StringNoCopy: (char *)UTF8String @@ -845,11 +845,11 @@ freeWhenDone: (bool)freeWhenDone { id ret = [self initWithUTF8String: UTF8String length: UTF8StringLength]; if (freeWhenDone) - free(UTF8String); + OFFreeMemory(UTF8String); return ret; } - (instancetype)initWithCString: (const char *)cString @@ -1013,17 +1013,17 @@ * to use -[initWithUTF8StringNoCopy:length:freeWhenDone:]. */ if (SIZE_MAX - (size_t)fileSize < 1) @throw [OFOutOfRangeException exception]; - tmp = of_alloc((size_t)fileSize + 1, 1); + tmp = OFAllocMemory((size_t)fileSize + 1, 1); @try { file = [[OFFile alloc] initWithPath: path mode: @"r"]; [file readIntoBuffer: tmp exactLength: (size_t)fileSize]; } @catch (id e) { - free(tmp); + OFFreeMemory(tmp); @throw e; } @finally { [file release]; } @@ -1037,20 +1037,20 @@ @try { self = [self initWithUTF8StringNoCopy: tmp length: (size_t)fileSize freeWhenDone: true]; } @catch (id e) { - free(tmp); + OFFreeMemory(tmp); @throw e; } } else { @try { self = [self initWithCString: tmp encoding: encoding length: (size_t)fileSize]; } @finally { - free(tmp); + OFFreeMemory(tmp); } } return self; } @@ -1372,25 +1372,25 @@ char *cString; size_t cStringLength; switch (encoding) { case OFStringEncodingUTF8: - cString = of_alloc((length * 4) + 1, 1); + cString = OFAllocMemory((length * 4) + 1, 1); @try { cStringLength = [self of_getCString: cString maxLength: (length * 4) + 1 encoding: OFStringEncodingUTF8 lossy: lossy]; } @catch (id e) { - free(cString); + OFFreeMemory(cString); @throw e; } @try { - cString = of_realloc(cString, cStringLength + 1, 1); + cString = OFResizeMemory(cString, cStringLength + 1, 1); } @catch (OFOutOfMemoryException *e) { /* We don't care, as we only tried to make it smaller */ } break; @@ -1405,19 +1405,19 @@ case OFStringEncodingCodepage850: case OFStringEncodingCodepage858: case OFStringEncodingMacRoman: case OFStringEncodingKOI8R: case OFStringEncodingKOI8U: - cString = of_alloc(length + 1, 1); + cString = OFAllocMemory(length + 1, 1); @try { cStringLength = [self of_getCString: cString maxLength: length + 1 encoding: encoding lossy: lossy]; } @catch (id e) { - free(cString); + OFFreeMemory(cString); @throw e; } break; default: @@ -1427,11 +1427,11 @@ @try { return [[OFData dataWithItemsNoCopy: cString count: cStringLength + 1 freeWhenDone: true] items]; } @catch (id e) { - free(cString); + OFFreeMemory(cString); @throw e; } } - (const char *)cStringWithEncoding: (OFStringEncoding)encoding @@ -1836,11 +1836,11 @@ pool = objc_autoreleasePoolPush(); searchCharacters = string.characters; - characters = of_alloc(range.length, sizeof(OFUnichar)); + characters = OFAllocMemory(range.length, sizeof(OFUnichar)); @try { [self getCharacters: characters inRange: range]; if (options & OFStringSearchBackwards) { for (size_t i = range.length - searchLength;; i--) { @@ -1865,11 +1865,11 @@ searchLength); } } } } @finally { - free(characters); + OFFreeMemory(characters); } objc_autoreleasePoolPop(pool); return OFRangeMake(OFNotFound, 0); @@ -1903,11 +1903,11 @@ return OFNotFound; if (range.length > SIZE_MAX / sizeof(OFUnichar)) @throw [OFOutOfRangeException exception]; - characters = of_alloc(range.length, sizeof(OFUnichar)); + characters = OFAllocMemory(range.length, sizeof(OFUnichar)); @try { [self getCharacters: characters inRange: range]; if (options & OFStringSearchBackwards) { for (size_t i = range.length - 1;; i--) { @@ -1926,11 +1926,11 @@ @selector(characterIsMember:), characters[i])) return range.location + i; } } @finally { - free(characters); + OFFreeMemory(characters); } return OFNotFound; } @@ -2111,11 +2111,11 @@ bool hasPrefix; if ((prefixLength = prefix.length) > self.length) return false; - tmp = of_alloc(prefixLength, sizeof(OFUnichar)); + tmp = OFAllocMemory(prefixLength, sizeof(OFUnichar)); @try { void *pool = objc_autoreleasePoolPush(); [self getCharacters: tmp inRange: OFRangeMake(0, prefixLength)]; @@ -2122,11 +2122,11 @@ hasPrefix = (memcmp(tmp, prefix.characters, prefixLength * sizeof(OFUnichar)) == 0); objc_autoreleasePoolPop(pool); } @finally { - free(tmp); + OFFreeMemory(tmp); } return hasPrefix; } @@ -2140,11 +2140,11 @@ if ((suffixLength = suffix.length) > self.length) return false; length = self.length; - tmp = of_alloc(suffixLength, sizeof(OFUnichar)); + tmp = OFAllocMemory(suffixLength, sizeof(OFUnichar)); @try { void *pool = objc_autoreleasePoolPush(); [self getCharacters: tmp inRange: OFRangeMake(length - suffixLength, @@ -2154,11 +2154,11 @@ hasSuffix = (memcmp(tmp, suffixCharacters, suffixLength * sizeof(OFUnichar)) == 0); objc_autoreleasePoolPop(pool); } @finally { - free(tmp); + OFFreeMemory(tmp); } return hasSuffix; } @@ -2530,20 +2530,20 @@ - (const OFUnichar *)characters { size_t length = self.length; OFUnichar *buffer; - buffer = of_alloc(length, sizeof(OFUnichar)); + buffer = OFAllocMemory(length, sizeof(OFUnichar)); @try { [self getCharacters: buffer inRange: OFRangeMake(0, length)]; return [[OFData dataWithItemsNoCopy: buffer count: length itemSize: sizeof(OFUnichar) freeWhenDone: true] items]; } @catch (id e) { - free(buffer); + OFFreeMemory(buffer); @throw e; } } - (const OFChar16 *)UTF16String @@ -2559,18 +2559,18 @@ OFChar16 *buffer; size_t j; bool swap = (byteOrder != OFByteOrderNative); /* Allocate memory for the worst case */ - buffer = of_alloc((length + 1) * 2, sizeof(OFChar16)); + buffer = OFAllocMemory((length + 1) * 2, sizeof(OFChar16)); j = 0; for (size_t i = 0; i < length; i++) { OFUnichar c = characters[i]; if (c > 0x10FFFF) { - free(buffer); + OFFreeMemory(buffer); @throw [OFInvalidEncodingException exception]; } if (swap) { if (c > 0xFFFF) { @@ -2589,11 +2589,11 @@ } } buffer[j] = 0; @try { - buffer = of_realloc(buffer, j + 1, sizeof(OFChar16)); + buffer = OFResizeMemory(buffer, j + 1, sizeof(OFChar16)); } @catch (OFOutOfMemoryException *e) { /* We don't care, as we only tried to make it smaller */ } objc_autoreleasePoolPop(pool); @@ -2602,11 +2602,11 @@ return [[OFData dataWithItemsNoCopy: buffer count: j + 1 itemSize: sizeof(OFChar16) freeWhenDone: true] items]; } @catch (id e) { - free(buffer); + OFFreeMemory(buffer); @throw e; } } - (size_t)UTF16StringLength @@ -2631,11 +2631,11 @@ - (const OFChar32 *)UTF32StringWithByteOrder: (OFByteOrder)byteOrder { size_t length = self.length; OFChar32 *buffer; - buffer = of_alloc(length + 1, sizeof(OFChar32)); + buffer = OFAllocMemory(length + 1, sizeof(OFChar32)); @try { [self getCharacters: buffer inRange: OFRangeMake(0, length)]; buffer[length] = 0; if (byteOrder != OFByteOrderNative) @@ -2645,11 +2645,11 @@ return [[OFData dataWithItemsNoCopy: buffer count: length + 1 itemSize: sizeof(OFChar32) freeWhenDone: true] items]; } @catch (id e) { - free(buffer); + OFFreeMemory(buffer); @throw e; } } - (OFData *)dataWithEncoding: (OFStringEncoding)encoding