From 01521697b00359af490a6702737dee6061a231f5 Mon Sep 17 00:00:00 2001 From: Roman Shterenzon Date: Fri, 13 Aug 2010 18:27:58 +0300 Subject: [PATCH 1/2] Fix a memory leak --- Classes/Framework/FMEngine.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Classes/Framework/FMEngine.m b/Classes/Framework/FMEngine.m index d48808b..dbb9197 100644 --- a/Classes/Framework/FMEngine.m +++ b/Classes/Framework/FMEngine.m @@ -55,9 +55,9 @@ - (void)performMethod:(NSString *)method withTarget:(id)target withParameters:(N request = [NSURLRequest requestWithURL:dataURL]; } else { #ifdef _USE_JSON_ - request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:[_LASTFM_BASEURL_ stringByAppendingString:@"?format=json"]]]; + request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[_LASTFM_BASEURL_ stringByAppendingString:@"?format=json"]]]; #else - request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:_LASTFM_BASEURL_]]; + request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:_LASTFM_BASEURL_]]; #endif [request setHTTPMethod:httpMethod]; [request setHTTPBody:[[self generatePOSTBodyFromDictionary:params] dataUsingEncoding:NSUTF8StringEncoding]]; @@ -101,9 +101,9 @@ - (NSData *)dataForMethod:(NSString *)method withParameters:(NSDictionary *)para request = [NSURLRequest requestWithURL:dataURL]; } else { #ifdef _USE_JSON_ - request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:[_LASTFM_BASEURL_ stringByAppendingString:@"?format=json"]]]; + request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[_LASTFM_BASEURL_ stringByAppendingString:@"?format=json"]]]; #else - request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:_LASTFM_BASEURL_]]; + request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:_LASTFM_BASEURL_]]; #endif [request setHTTPMethod:httpMethod]; From 55779a9f4c9d1117c85780a48cd6a2fa5114e123 Mon Sep 17 00:00:00 2001 From: Roman Shterenzon Date: Fri, 20 Aug 2010 19:20:29 +0300 Subject: [PATCH 2/2] Bugfix: pass pointer to NSError* --- Classes/Framework/FMEngine.h | 2 +- Classes/Framework/FMEngine.m | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Classes/Framework/FMEngine.h b/Classes/Framework/FMEngine.h index d7b35cb..abd58c8 100644 --- a/Classes/Framework/FMEngine.h +++ b/Classes/Framework/FMEngine.h @@ -33,7 +33,7 @@ - (NSURL *)generateURLFromDictionary:(NSDictionary *)dict; - (void)performMethod:(NSString *)method withTarget:(id)target withParameters:(NSDictionary *)params andAction:(SEL)callback useSignature:(BOOL)useSig httpMethod:(NSString *)httpMethod; -- (NSData *)dataForMethod:(NSString *)method withParameters:(NSDictionary *)params useSignature:(BOOL)useSig httpMethod:(NSString *)httpMethod error:(NSError *)err; +- (NSData *)dataForMethod:(NSString *)method withParameters:(NSDictionary *)params useSignature:(BOOL)useSig httpMethod:(NSString *)httpMethod error:(NSError **)err; @end diff --git a/Classes/Framework/FMEngine.m b/Classes/Framework/FMEngine.m index dbb9197..ed452db 100644 --- a/Classes/Framework/FMEngine.m +++ b/Classes/Framework/FMEngine.m @@ -74,7 +74,7 @@ - (void)performMethod:(NSString *)method withTarget:(id)target withParameters:(N } -- (NSData *)dataForMethod:(NSString *)method withParameters:(NSDictionary *)params useSignature:(BOOL)useSig httpMethod:(NSString *)httpMethod error:(NSError *)err { +- (NSData *)dataForMethod:(NSString *)method withParameters:(NSDictionary *)params useSignature:(BOOL)useSig httpMethod:(NSString *)httpMethod error:(NSError **)err { NSString *dataSig; NSMutableURLRequest *request; NSMutableDictionary *tempDict = [[NSMutableDictionary alloc] initWithDictionary:params]; @@ -110,7 +110,7 @@ - (NSData *)dataForMethod:(NSString *)method withParameters:(NSDictionary *)para [request setHTTPBody:[[self generatePOSTBodyFromDictionary:params] dataUsingEncoding:NSUTF8StringEncoding]]; } - NSData *returnData = [FMEngineURLConnection sendSynchronousRequest:request returningResponse:nil error:&err]; + NSData *returnData = [FMEngineURLConnection sendSynchronousRequest:request returningResponse:nil error:err]; return returnData; }