# HG changeset patch # User Anton Malmygin # Date 1439852901 -7200 # Node ID 14f50dde3e8cd1f142eb8987ab453e9aa62d29b3 # Parent 9b5f60bc059e482f748794b6542aa74ca2617db5 - Using of @autoreleasepool is better diff -r 9b5f60bc059e -r 14f50dde3e8c project_files/HedgewarsMobile/Classes/Appirater.m --- a/project_files/HedgewarsMobile/Classes/Appirater.m Tue Aug 18 00:51:23 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/Appirater.m Tue Aug 18 01:08:21 2015 +0200 @@ -47,7 +47,7 @@ } -(void) appLaunchedHandler { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + @autoreleasepool { if (APPIRATER_DEBUG) { [self performSelectorOnMainThread:@selector(showPrompt) withObject:nil waitUntilDone:NO]; @@ -116,7 +116,7 @@ if (!willShowPrompt) [self autorelease]; - [pool release]; + } } -(void) showPrompt { diff -r 9b5f60bc059e -r 14f50dde3e8c project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m --- a/project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m Tue Aug 18 00:51:23 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m Tue Aug 18 01:08:21 2015 +0200 @@ -214,7 +214,8 @@ // this is launched as thread and handles all IPC with engine -(void) engineProtocol:(id) object { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + @autoreleasepool { + NSDictionary *gameConfig = (NSDictionary *)object; NSMutableArray *statsArray = nil; TCPsocket sd; @@ -403,8 +404,9 @@ [HWUtils freePort:self.enginePort]; SDLNet_TCP_Close(csd); SDLNet_Quit(); + + } - [pool release]; // Invoking this method should be avoided as it does not give your thread a chance // to clean up any resources it allocated during its execution. //[NSThread exit]; diff -r 9b5f60bc059e -r 14f50dde3e8c project_files/HedgewarsMobile/Classes/GameConfigViewController.m --- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Tue Aug 18 00:51:23 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Tue Aug 18 01:08:21 2015 +0200 @@ -230,7 +230,8 @@ } -(void) loadNiceHogs { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + @autoreleasepool { + srand(time(NULL)); NSString *filePath = [[NSString alloc] initWithFormat:@"%@/Hedgehog/Idle.png",GRAPHICS_DIRECTORY()]; UIImage *hogSprite = [[UIImage alloc] initWithContentsOfFile:filePath]; @@ -284,7 +285,8 @@ [self.view addSubview:self.imgContainer]; [hogSprite release]; - [pool drain]; + + } } -(void) viewDidLoad { diff -r 9b5f60bc059e -r 14f50dde3e8c project_files/HedgewarsMobile/Classes/MXAudioPlayerFadeOperation.m --- a/project_files/HedgewarsMobile/Classes/MXAudioPlayerFadeOperation.m Tue Aug 18 00:51:23 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/MXAudioPlayerFadeOperation.m Tue Aug 18 01:08:21 2015 +0200 @@ -79,7 +79,8 @@ } - (void)main { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + @autoreleasepool { + [NSThread sleepForTimeInterval:_delay]; if ([self.audioPlayer isKindOfClass:[AVAudioPlayer class]]) { [self beginFadeOperation]; @@ -88,7 +89,7 @@ ALog(@"AudioPlayerFadeOperation began with invalid AVAudioPlayer"); } - [pool release]; + } } - (void)beginFadeOperation { diff -r 9b5f60bc059e -r 14f50dde3e8c project_files/HedgewarsMobile/Classes/MapPreviewButtonView.m --- a/project_files/HedgewarsMobile/Classes/MapPreviewButtonView.m Tue Aug 18 00:51:23 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/MapPreviewButtonView.m Tue Aug 18 01:08:21 2015 +0200 @@ -151,7 +151,8 @@ } -(void) drawingThread { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + @autoreleasepool { + uint8_t unpackedMap[128*32*8]; [self engineProtocol:unpackedMap]; @@ -179,8 +180,8 @@ [self performSelectorOnMainThread:@selector(removeIndicator) withObject:nil waitUntilDone:NO]; - - [pool release]; + + } } -(void) updatePreviewWithSeed:(NSString *)seed { diff -r 9b5f60bc059e -r 14f50dde3e8c project_files/HedgewarsMobile/Classes/ServerProtocolNetwork.m --- a/project_files/HedgewarsMobile/Classes/ServerProtocolNetwork.m Tue Aug 18 00:51:23 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/ServerProtocolNetwork.m Tue Aug 18 01:08:21 2015 +0200 @@ -82,7 +82,8 @@ } -(void) serverProtocol { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + @autoreleasepool { + IPaddress ip; BOOL clientQuit = NO; char *buffer = (char *)malloc(sizeof(char)*BUFFER_SIZE); @@ -206,7 +207,7 @@ SDLNet_TCP_Close(self.ssd); SDLNet_Quit(); - [pool release]; + } } @end