Ben Copsey

Fix leaking CoreFoundation stuff when running with GC

... ... @@ -30,7 +30,7 @@
#pragma mark utilities
- (NSString*)encodeURL:(NSString *)string
{
NSString *newString = [(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)string, NULL, CFSTR(":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`"), CFStringConvertNSStringEncodingToEncoding([self stringEncoding])) autorelease];
NSString *newString = NSMakeCollectable([(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)string, NULL, CFSTR(":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`"), CFStringConvertNSStringEncodingToEncoding([self stringEncoding])) autorelease]);
if (newString) {
return newString;
}
... ...
... ... @@ -23,7 +23,7 @@
// Automatically set on build
NSString *ASIHTTPRequestVersion = @"v1.6.2-22 2010-06-19";
NSString *ASIHTTPRequestVersion = @"v1.6.2-23 2010-06-20";
NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain";
... ... @@ -871,13 +871,13 @@ static BOOL isiPhoneOS2;
// Can't detect proxies in 2.2.1 Simulator
NSDictionary *proxySettings = [NSMutableDictionary dictionary];
#else
NSDictionary *proxySettings = [(NSDictionary *)CFNetworkCopySystemProxySettings() autorelease];
NSDictionary *proxySettings = NSMakeCollectable([(NSDictionary *)CFNetworkCopySystemProxySettings() autorelease]);
#endif
#else
NSDictionary *proxySettings = [(NSDictionary *)SCDynamicStoreCopyProxies(NULL) autorelease];
NSDictionary *proxySettings = NSMakeCollectable([(NSDictionary *)SCDynamicStoreCopyProxies(NULL) autorelease]);
#endif
proxies = [(NSArray *)CFNetworkCopyProxiesForURL((CFURLRef)[self url], (CFDictionaryRef)proxySettings) autorelease];
proxies = NSMakeCollectable([(NSArray *)CFNetworkCopyProxiesForURL((CFURLRef)[self url], (CFDictionaryRef)proxySettings) autorelease]);
// Now check to see if the proxy settings contained a PAC url, we need to run the script to get the real list of proxies if so
NSDictionary *settings = [proxies objectAtIndex:0];
... ... @@ -1169,7 +1169,7 @@ static BOOL isiPhoneOS2;
[self setLastBytesSent:totalBytesSent];
// Find out how much data we've uploaded so far
[self setTotalBytesSent:[[(NSNumber *)CFReadStreamCopyProperty((CFReadStreamRef)[self readStream], kCFStreamPropertyHTTPRequestBytesWrittenCount) autorelease] unsignedLongLongValue]];
[self setTotalBytesSent:[NSMakeCollectable([(NSNumber *)CFReadStreamCopyProperty((CFReadStreamRef)[self readStream], kCFStreamPropertyHTTPRequestBytesWrittenCount) autorelease]) unsignedLongLongValue]];
if (totalBytesSent > lastBytesSent) {
// We've uploaded more data, reset the timeout
... ... @@ -1772,7 +1772,7 @@ static BOOL isiPhoneOS2;
if ([self shouldAttemptPersistentConnection]) {
NSString *connectionHeader = [[[self responseHeaders] objectForKey:@"Connection"] lowercaseString];
NSString *httpVersion = [(NSString *)CFHTTPMessageCopyVersion(message) autorelease];
NSString *httpVersion = NSMakeCollectable([(NSString *)CFHTTPMessageCopyVersion(message) autorelease]);
// Don't re-use the connection if the server is HTTP 1.0 and didn't send Connection: Keep-Alive
if (![httpVersion isEqualToString:(NSString *)kCFHTTPVersion1_0] || [connectionHeader isEqualToString:@"keep-alive"]) {
... ... @@ -2551,7 +2551,7 @@ static BOOL isiPhoneOS2;
[progressLock lock];
// Find out how much data we've uploaded so far
[self setLastBytesSent:totalBytesSent];
[self setTotalBytesSent:[[(NSNumber *)CFReadStreamCopyProperty((CFReadStreamRef)[self readStream], kCFStreamPropertyHTTPRequestBytesWrittenCount) autorelease] unsignedLongLongValue]];
[self setTotalBytesSent:[NSMakeCollectable([(NSNumber *)CFReadStreamCopyProperty((CFReadStreamRef)[self readStream], kCFStreamPropertyHTTPRequestBytesWrittenCount) autorelease]) unsignedLongLongValue]];
[self setComplete:YES];
[self updateProgressIndicators];
... ... @@ -2636,6 +2636,17 @@ static BOOL isiPhoneOS2;
- (void)markAsFinished
{
[[self retain] autorelease];
// release won't be called when running with GC, so we'll clean these up now
if (request) {
CFMakeCollectable(request);
}
if (requestAuthentication) {
CFMakeCollectable(requestAuthentication);
}
if (proxyAuthentication) {
CFMakeCollectable(proxyAuthentication);
}
[self willChangeValueForKey:@"isFinished"];
[self setInProgress:NO];
[self didChangeValueForKey:@"isFinished"];
... ... @@ -2666,7 +2677,7 @@ static BOOL isiPhoneOS2;
- (void)handleStreamError
{
NSError *underlyingError = [(NSError *)CFReadStreamCopyError((CFReadStreamRef)[self readStream]) autorelease];
NSError *underlyingError = NSMakeCollectable([(NSError *)CFReadStreamCopyError((CFReadStreamRef)[self readStream]) autorelease]);
[self cancelLoad];
... ... @@ -3393,10 +3404,10 @@ static BOOL isiPhoneOS2;
}
// Obtain the list of proxies by running the autoconfiguration script
#if TARGET_IPHONE_SIMULATOR && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_3_0
NSArray *proxies = [(NSArray *)CFNetworkCopyProxiesForAutoConfigurationScript((CFStringRef)script,(CFURLRef)theURL) autorelease];
NSArray *proxies = NSMakeCollectable([(NSArray *)CFNetworkCopyProxiesForAutoConfigurationScript((CFStringRef)script,(CFURLRef)theURL) autorelease]);
#else
CFErrorRef err2 = NULL;
NSArray *proxies = [(NSArray *)CFNetworkCopyProxiesForAutoConfigurationScript((CFStringRef)script,(CFURLRef)theURL, &err2) autorelease];
NSArray *proxies = NSMakeCollectable([(NSArray *)CFNetworkCopyProxiesForAutoConfigurationScript((CFStringRef)script,(CFURLRef)theURL, &err2) autorelease]);
if (err2) {
return nil;
}
... ... @@ -3420,7 +3431,7 @@ static BOOL isiPhoneOS2;
if (!MIMEType) {
return @"application/octet-stream";
}
return [(NSString *)MIMEType autorelease];
return NSMakeCollectable([(NSString *)MIMEType autorelease]);
}
#pragma mark bandwidth measurement / throttling
... ...
This diff was suppressed by a .gitattributes entry.