@@ -840,11 +840,11 @@ @try { ret = [self initWithUTF8String: UTF8String]; } @finally { if (freeWhenDone) - free(UTF8String); + of_free(UTF8String); } return ret; } @@ -857,11 +857,11 @@ @try { ret = [self initWithUTF8String: UTF8String length: UTF8StringLength]; } @finally { if (freeWhenDone) - free(UTF8String); + of_free(UTF8String); } return ret; } @@ -1027,22 +1027,19 @@ * to use -[initWithUTF8StringNoCopy:length:freeWhenDone:]. */ if (SIZE_MAX - (size_t)fileSize < 1) @throw [OFOutOfRangeException exception]; - if ((tmp = malloc((size_t)fileSize + 1)) == NULL) - @throw [OFOutOfMemoryException - exceptionWithRequestedSize: (size_t)fileSize]; - + tmp = of_malloc(1, (size_t)fileSize + 1); @try { file = [[OFFile alloc] initWithPath: path mode: @"r"]; [file readIntoBuffer: tmp exactLength: (size_t)fileSize]; } @catch (id e) { - free(tmp); + of_free(tmp); @throw e; } @finally { [file release]; } @@ -1060,11 +1057,11 @@ @try { self = [self initWithCString: tmp encoding: encoding length: (size_t)fileSize]; } @finally { - free(tmp); + of_free(tmp); } } return self; } @@ -1858,14 +1855,11 @@ pool = objc_autoreleasePoolPush(); searchCharacters = string.characters; - if ((characters = malloc(range.length * sizeof(of_unichar_t))) == NULL) - @throw [OFOutOfMemoryException exceptionWithRequestedSize: - range.length * sizeof(of_unichar_t)]; - + characters = of_malloc(range.length, sizeof(of_unichar_t)); @try { [self getCharacters: characters inRange: range]; if (options & OF_STRING_SEARCH_BACKWARDS) { @@ -1891,11 +1885,11 @@ searchLength); } } } } @finally { - free(characters); + of_free(characters); } objc_autoreleasePoolPop(pool); return of_range(OF_NOT_FOUND, 0); @@ -1929,14 +1923,11 @@ return OF_NOT_FOUND; if (range.length > SIZE_MAX / sizeof(of_unichar_t)) @throw [OFOutOfRangeException exception]; - if ((characters = malloc(range.length * sizeof(of_unichar_t))) == NULL) - @throw [OFOutOfMemoryException exceptionWithRequestedSize: - range.length * sizeof(of_unichar_t)]; - + characters = of_malloc(range.length, sizeof(of_unichar_t)); @try { [self getCharacters: characters inRange: range]; if (options & OF_STRING_SEARCH_BACKWARDS) { @@ -1956,11 +1947,11 @@ @selector(characterIsMember:), characters[i])) return range.location + i; } } @finally { - free(characters); + of_free(characters); } return OF_NOT_FOUND; }