From 6f63157e33149226bfc2f014748cb5ef5c9a3a9b Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 25 Mar 2012 02:19:33 -0700 Subject: [PATCH] fixes a few memory leaks. ARC is already starting to cripple my memory management code. Time to make the switch on AFNetworking. --- AFNetworking/AFDownloadRequestOperation.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AFNetworking/AFDownloadRequestOperation.m b/AFNetworking/AFDownloadRequestOperation.m index a1ab142..ca33ff1 100644 --- a/AFNetworking/AFDownloadRequestOperation.m +++ b/AFNetworking/AFDownloadRequestOperation.m @@ -60,7 +60,7 @@ typedef void (^AFURLConnectionProgressiveOperationProgressBlock)(NSInteger bytes success:(void (^)(NSURLRequest *request, NSString *filePath))success failure:(void (^)(NSURLRequest *request, NSError *error))failure { - AFDownloadRequestOperation *requestOperation = [[self alloc] initWithRequest:urlRequest targetPath:(NSString *)targetPath shouldResume:shouldResume]; + AFDownloadRequestOperation *requestOperation = [[[self alloc] initWithRequest:urlRequest targetPath:(NSString *)targetPath shouldResume:shouldResume] autorelease]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { if (success) { @@ -87,8 +87,8 @@ typedef void (^AFURLConnectionProgressiveOperationProgressBlock)(NSInteger bytes NSFileManager *fileMan = [[NSFileManager alloc] init]; if(![fileMan createDirectoryAtPath:cacheFolder withIntermediateDirectories:YES attributes:nil error:&error]) { NSLog(@"Failed to create cache directory at %@", cacheFolder); - [fileMan release]; } + [fileMan release]; }); return cacheFolder; } @@ -146,7 +146,7 @@ typedef void (^AFURLConnectionProgressiveOperationProgressBlock)(NSInteger bytes if (shouldResume) { unsigned long long downloadedBytes = [self fileSizeForPath:tempPath]; if (downloadedBytes > 0) { - NSMutableURLRequest *mutableURLRequest = [urlRequest mutableCopy]; + NSMutableURLRequest *mutableURLRequest = [[urlRequest mutableCopy] autorelease]; NSString *requestRange = [NSString stringWithFormat:@"bytes=%llu-", downloadedBytes]; [mutableURLRequest setValue:requestRange forHTTPHeaderField:@"Range"]; self.request = mutableURLRequest;