Replaced manual NSAutoreleasePool handing with @autorelease

This commit is contained in:
stopiccot 2013-01-06 19:04:53 +03:00
parent e1f76ef0ea
commit 929560081c
11 changed files with 699 additions and 769 deletions

View file

@ -20,25 +20,22 @@ FILE* SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode)
return fopen(file, mode);
}
NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
@autoreleasepool {
NSFileManager* file_manager = [NSFileManager defaultManager];
NSString* resource_path = [[NSBundle mainBundle] resourcePath];
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
NSFileManager* file_manager = [NSFileManager defaultManager];
NSString* resource_path = [[NSBundle mainBundle] resourcePath];
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component];
if([file_manager fileExistsAtPath:full_path_with_file_to_try])
{
fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
}
else
{
fp = fopen(file, mode);
}
[autorelease_pool drain];
NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component];
if([file_manager fileExistsAtPath:full_path_with_file_to_try])
{
fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
}
else
{
fp = fopen(file, mode);
}
}
return fp;
}