@@ -22,17 +22,17 @@ #include #import "OFString.h" #import "OFMutableString_UTF8.h" -#import "OFAutoreleasePool.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFNotImplementedException.h" #import "OFOutOfRangeException.h" +#import "autorelease.h" #import "macros.h" #import "of_asprintf.h" #import "unicode.h" @@ -258,11 +258,11 @@ - (void)_convertWithWordStartTable: (const of_unichar_t *const[])startTable wordMiddleTable: (const of_unichar_t *const[])middleTable wordStartTableSize: (size_t)startTableSize wordMiddleTableSize: (size_t)middleTableSize { - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + void *pool = objc_autoreleasePoolPush(); const of_unichar_t *string = [self unicodeString]; size_t i, length = [self length]; BOOL isStart = YES; for (i = 0; i < length; i++) { @@ -293,11 +293,11 @@ isStart = NO; break; } } - [pool release]; + objc_autoreleasePoolPop(pool); } - (void)setCharacter: (of_unichar_t)character atIndex: (size_t)index { @@ -305,50 +305,50 @@ selector: _cmd]; } - (void)appendUTF8String: (const char*)UTF8String { - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + void *pool = objc_autoreleasePoolPush(); [self appendString: [OFString stringWithUTF8String: UTF8String]]; - [pool release]; + objc_autoreleasePoolPop(pool); } - (void)appendUTF8String: (const char*)UTF8String withLength: (size_t)UTF8StringLength { - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + void *pool = objc_autoreleasePoolPush(); [self appendString: [OFString stringWithUTF8String: UTF8String length: UTF8StringLength]]; - [pool release]; + objc_autoreleasePoolPop(pool); } - (void)appendCString: (const char*)cString withEncoding: (of_string_encoding_t)encoding { - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + void *pool = objc_autoreleasePoolPush(); [self appendString: [OFString stringWithCString: cString encoding: encoding]]; - [pool release]; + objc_autoreleasePoolPop(pool); } - (void)appendCString: (const char*)cString withEncoding: (of_string_encoding_t)encoding length: (size_t)cStringLength { - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + void *pool = objc_autoreleasePoolPush(); [self appendString: [OFString stringWithCString: cString encoding: encoding length: cStringLength]]; - [pool release]; + objc_autoreleasePoolPop(pool); } - (void)appendString: (OFString*)string { return [self insertString: string @@ -463,11 +463,11 @@ - (void)replaceOccurrencesOfString: (OFString*)string withString: (OFString*)replacement inRange: (of_range_t)range { - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init], *pool2; + void *pool = objc_autoreleasePoolPush(), *pool2; const of_unichar_t *unicodeString; const of_unichar_t *searchString = [string unicodeString]; size_t searchLength = [string length]; size_t replacementLength = [replacement length]; size_t i; @@ -474,15 +474,15 @@ if (range.start + range.length > [self length]) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; if (searchLength > range.length) { - [pool release]; + objc_autoreleasePoolPop(pool); return; } - pool2 = [[OFAutoreleasePool alloc] init]; + pool2 = objc_autoreleasePoolPush(); unicodeString = [self unicodeString]; for (i = range.start; i <= range.length - searchLength; i++) { if (memcmp(unicodeString + i, searchString, searchLength * sizeof(of_unichar_t))) @@ -494,16 +494,17 @@ range.length -= searchLength; range.length += replacementLength; i += replacementLength - 1; - [pool2 releaseObjects]; + objc_autoreleasePoolPop(pool2); + pool2 = objc_autoreleasePoolPush(); unicodeString = [self unicodeString]; } - [pool release]; + objc_autoreleasePoolPop(pool); } - (void)deleteLeadingWhitespaces { size_t i, length = [self length];