@@ -25,11 +25,10 @@ #import "OFString.h" #import "OFURL.h" #import "OFTCPSocket.h" #import "OFDictionary.h" #import "OFDataArray.h" -#import "OFAutoreleasePool.h" #import "OFHTTPRequestFailedException.h" #import "OFInvalidEncodingException.h" #import "OFInvalidFormatException.h" #import "OFInvalidServerReplyException.h" @@ -36,10 +35,11 @@ #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" #import "OFUnsupportedProtocolException.h" #import "OFUnsupportedVersionException.h" +#import "autorelease.h" #import "macros.h" Class of_http_request_tls_socket_class = Nil; static OF_INLINE void @@ -185,11 +185,11 @@ return [self performWithRedirects: 10]; } - (OFHTTPRequestResult*)performWithRedirects: (size_t)redirects { - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + void *pool = objc_autoreleasePoolPush(); OFString *scheme = [URL scheme]; OFTCPSocket *sock; OFHTTPRequestResult *result; OFString *line, *path, *version; OFMutableDictionary *serverHeaders; @@ -365,11 +365,11 @@ requestType = OF_HTTP_REQUEST_TYPE_GET; [queryString release]; queryString = nil; } - [pool release]; + objc_autoreleasePoolPop(pool); return [self performWithRedirects: redirects - 1]; } [serverHeaders setObject: value @@ -395,14 +395,13 @@ } buffer = [self allocMemoryWithSize: of_pagesize]; bytesReceived = 0; @try { - OFAutoreleasePool *pool2 = [[OFAutoreleasePool alloc] init]; - if (chunked) { for (;;) { + void *pool2 = objc_autoreleasePoolPush(); size_t pos, toRead; @try { line = [sock readLine]; } @catch (OFInvalidEncodingException *e) { @@ -437,11 +436,13 @@ length: length]; [delegate request: self didReceiveData: buffer withLength: length]; - [pool2 releaseObjects]; + + objc_autoreleasePoolPop(pool2); + pool2 = objc_autoreleasePoolPush(); bytesReceived += length; [data addItemsFromCArray: buffer count: length]; @@ -457,22 +458,25 @@ if (![line isEqual: @""]) @throw [OFInvalidServerReplyException exceptionWithClass: [self class]]; - [pool2 releaseObjects]; + objc_autoreleasePoolPop(pool2); } } else { size_t length; while ((length = [sock readIntoBuffer: buffer length: of_pagesize]) > 0) { + void *pool2 = objc_autoreleasePoolPush(); + [delegate request: self didReceiveData: buffer withLength: length]; - [pool2 releaseObjects]; + + objc_autoreleasePoolPop(pool2); bytesReceived += length; [data addItemsFromCArray: buffer count: length]; @@ -479,12 +483,10 @@ if (contentLengthHeader != nil && bytesReceived >= contentLength) break; } } - - [pool2 release]; } @finally { [self freeMemory: buffer]; } [sock close]; @@ -518,11 +520,11 @@ exceptionWithClass: [self class] HTTPRequest: self result: result]; } - [pool release]; + objc_autoreleasePoolPop(pool); return [result autorelease]; } @end