Replaced manual NSAutoreleasePool handing with @autorelease
authorstopiccot <alexey.petruchik@gmail.com>
Sun, 06 Jan 2013 19:04:53 +0300
changeset 6832 156e608ec4ef
parent 6831 935b871e1ffe
child 6833 c34a64af7751
Replaced manual NSAutoreleasePool handing with @autorelease
src/file/cocoa/SDL_rwopsbundlesupport.m
src/video/cocoa/SDL_cocoaclipboard.m
src/video/cocoa/SDL_cocoaevents.m
src/video/cocoa/SDL_cocoakeyboard.m
src/video/cocoa/SDL_cocoamessagebox.m
src/video/cocoa/SDL_cocoamouse.m
src/video/cocoa/SDL_cocoaopengl.m
src/video/cocoa/SDL_cocoashape.m
src/video/cocoa/SDL_cocoavideo.m
src/video/cocoa/SDL_cocoawindow.m
test/automated/rwops/TestSupportRWops_Cocoa.m
--- a/src/file/cocoa/SDL_rwopsbundlesupport.m	Fri Feb 01 17:09:01 2013 -0800
+++ b/src/file/cocoa/SDL_rwopsbundlesupport.m	Sun Jan 06 19:04:53 2013 +0300
@@ -20,25 +20,22 @@
 		return fopen(file, mode);
 	}
 
-	NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
-
+	@autoreleasepool {
+        NSFileManager* file_manager = [NSFileManager defaultManager];
+        NSString* resource_path = [[NSBundle mainBundle] resourcePath];
 
-	NSFileManager* file_manager = [NSFileManager defaultManager];
-	NSString* resource_path = [[NSBundle mainBundle] resourcePath];
-
-	NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
+        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;
 }
--- a/src/video/cocoa/SDL_cocoaclipboard.m	Fri Feb 01 17:09:01 2013 -0800
+++ b/src/video/cocoa/SDL_cocoaclipboard.m	Sun Jan 06 19:04:53 2013 +0300
@@ -45,51 +45,46 @@
 Cocoa_SetClipboardText(_THIS, const char *text)
 {
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
-    NSAutoreleasePool *pool;
+
     NSPasteboard *pasteboard;
     NSString *format = GetTextFormat(_this);
 
-    pool = [[NSAutoreleasePool alloc] init];
-
-    pasteboard = [NSPasteboard generalPasteboard];
-    data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
-    [pasteboard setString:[NSString stringWithUTF8String:text] forType:format];
-
-    [pool release];
-
+    @autoreleasepool {
+        pasteboard = [NSPasteboard generalPasteboard];
+        data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
+        [pasteboard setString:[NSString stringWithUTF8String:text] forType:format];
+    }
+    
     return 0;
 }
 
 char *
 Cocoa_GetClipboardText(_THIS)
 {
-    NSAutoreleasePool *pool;
     NSPasteboard *pasteboard;
     NSString *format = GetTextFormat(_this);
     NSString *available;
     char *text;
 
-    pool = [[NSAutoreleasePool alloc] init];
-
-    pasteboard = [NSPasteboard generalPasteboard];
-    available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]];
-    if ([available isEqualToString:format]) {
-        NSString* string;
-        const char *utf8;
+    @autoreleasepool {
+        pasteboard = [NSPasteboard generalPasteboard];
+        available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]];
+        if ([available isEqualToString:format]) {
+            NSString* string;
+            const char *utf8;
 
-        string = [pasteboard stringForType:format];
-        if (string == nil) {
-            utf8 = "";
+            string = [pasteboard stringForType:format];
+            if (string == nil) {
+                utf8 = "";
+            } else {
+                utf8 = [string UTF8String];
+            }
+            text = SDL_strdup(utf8);
         } else {
-            utf8 = [string UTF8String];
+            text = SDL_strdup("");
         }
-        text = SDL_strdup(utf8);
-    } else {
-        text = SDL_strdup("");
     }
-
-    [pool release];
-
+    
     return text;
 }
 
@@ -108,22 +103,19 @@
 void
 Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
 {
-    NSAutoreleasePool *pool;
     NSPasteboard *pasteboard;
     NSInteger count;
 
-    pool = [[NSAutoreleasePool alloc] init];
-
-    pasteboard = [NSPasteboard generalPasteboard];
-    count = [pasteboard changeCount];
-    if (count != data->clipboard_count) {
-        if (data->clipboard_count) {
-            SDL_SendClipboardUpdate();
+    @autoreleasepool {
+        pasteboard = [NSPasteboard generalPasteboard];
+        count = [pasteboard changeCount];
+        if (count != data->clipboard_count) {
+            if (data->clipboard_count) {
+                SDL_SendClipboardUpdate();
+            }
+            data->clipboard_count = count;
         }
-        data->clipboard_count = count;
     }
-
-    [pool release];
 }
 
 #endif /* SDL_VIDEO_DRIVER_COCOA */
--- a/src/video/cocoa/SDL_cocoaevents.m	Fri Feb 01 17:09:01 2013 -0800
+++ b/src/video/cocoa/SDL_cocoaevents.m	Sun Jan 06 19:04:53 2013 +0300
@@ -158,33 +158,30 @@
 {
     /* This can get called more than once! Be careful what you initialize! */
     ProcessSerialNumber psn;
-    NSAutoreleasePool *pool;
 
     if (!GetCurrentProcess(&psn)) {
         TransformProcessType(&psn, kProcessTransformToForegroundApplication);
         SetFrontProcess(&psn);
     }
 
-    pool = [[NSAutoreleasePool alloc] init];
-    if (NSApp == nil) {
-        [NSApplication sharedApplication];
+    @autoreleasepool {
+        if (NSApp == nil) {
+            [NSApplication sharedApplication];
 
-        if ([NSApp mainMenu] == nil) {
-            CreateApplicationMenus();
+            if ([NSApp mainMenu] == nil) {
+                CreateApplicationMenus();
+            }
+            [NSApp finishLaunching];
         }
-        [NSApp finishLaunching];
+        if ([NSApp delegate] == nil) {
+            [NSApp setDelegate:[[SDLAppDelegate alloc] init]];
+        }
     }
-    if ([NSApp delegate] == nil) {
-        [NSApp setDelegate:[[SDLAppDelegate alloc] init]];
-    }
-    [pool release];
 }
 
 void
 Cocoa_PumpEvents(_THIS)
 {
-    NSAutoreleasePool *pool;
-
     /* Update activity every 30 seconds to prevent screensaver */
     if (_this->suspend_screensaver) {
         SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
@@ -196,39 +193,39 @@
         }
     }
 
-    pool = [[NSAutoreleasePool alloc] init];
-    for ( ; ; ) {
-        NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
-        if ( event == nil ) {
-            break;
+    @autoreleasepool {
+        for ( ; ; ) {
+            NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
+            if ( event == nil ) {
+                break;
+            }
+            
+            switch ([event type]) {
+            case NSLeftMouseDown:
+            case NSOtherMouseDown:
+            case NSRightMouseDown:
+            case NSLeftMouseUp:
+            case NSOtherMouseUp:
+            case NSRightMouseUp:
+            case NSLeftMouseDragged:
+            case NSRightMouseDragged:
+            case NSOtherMouseDragged: /* usually middle mouse dragged */
+            case NSMouseMoved:
+            case NSScrollWheel:
+                Cocoa_HandleMouseEvent(_this, event);
+                break;
+            case NSKeyDown:
+            case NSKeyUp:
+            case NSFlagsChanged:
+                Cocoa_HandleKeyEvent(_this, event);
+                break;
+            default:
+                break;
+            }
+            /* Pass through to NSApp to make sure everything stays in sync */
+            [NSApp sendEvent:event];
         }
-		
-        switch ([event type]) {
-        case NSLeftMouseDown:
-        case NSOtherMouseDown:
-        case NSRightMouseDown:
-        case NSLeftMouseUp:
-        case NSOtherMouseUp:
-        case NSRightMouseUp:
-        case NSLeftMouseDragged:
-        case NSRightMouseDragged:
-        case NSOtherMouseDragged: /* usually middle mouse dragged */
-        case NSMouseMoved:
-        case NSScrollWheel:
-            Cocoa_HandleMouseEvent(_this, event);
-            break;
-        case NSKeyDown:
-        case NSKeyUp:
-        case NSFlagsChanged:
-            Cocoa_HandleKeyEvent(_this, event);
-            break;
-        default:
-            break;
-        }
-        /* Pass through to NSApp to make sure everything stays in sync */
-        [NSApp sendEvent:event];
     }
-    [pool release];
 }
 
 #endif /* SDL_VIDEO_DRIVER_COCOA */
--- a/src/video/cocoa/SDL_cocoakeyboard.m	Fri Feb 01 17:09:01 2013 -0800
+++ b/src/video/cocoa/SDL_cocoakeyboard.m	Sun Jan 06 19:04:53 2013 +0300
@@ -625,28 +625,27 @@
 Cocoa_StartTextInput(_THIS)
 {
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    NSView *parentView = [[NSApp keyWindow] contentView];
+    @autoreleasepool {
+        NSView *parentView = [[NSApp keyWindow] contentView];
 
-    /* We only keep one field editor per process, since only the front most
-     * window can receive text input events, so it make no sense to keep more
-     * than one copy. When we switched to another window and requesting for
-     * text input, simply remove the field editor from its superview then add
-     * it to the front most window's content view */
-    if (!data->fieldEdit) {
-        data->fieldEdit =
-            [[SDLTranslatorResponder alloc] initWithFrame: NSMakeRect(0.0, 0.0, 0.0, 0.0)];
-    }
+        /* We only keep one field editor per process, since only the front most
+         * window can receive text input events, so it make no sense to keep more
+         * than one copy. When we switched to another window and requesting for
+         * text input, simply remove the field editor from its superview then add
+         * it to the front most window's content view */
+        if (!data->fieldEdit) {
+            data->fieldEdit =
+                [[SDLTranslatorResponder alloc] initWithFrame: NSMakeRect(0.0, 0.0, 0.0, 0.0)];
+        }
 
-    if (![[data->fieldEdit superview] isEqual: parentView])
-    {
-        // DEBUG_IME(@"add fieldEdit to window contentView");
-        [data->fieldEdit removeFromSuperview];
-        [parentView addSubview: data->fieldEdit];
-        [[NSApp keyWindow] makeFirstResponder: data->fieldEdit];
+        if (![[data->fieldEdit superview] isEqual: parentView])
+        {
+            // DEBUG_IME(@"add fieldEdit to window contentView");
+            [data->fieldEdit removeFromSuperview];
+            [parentView addSubview: data->fieldEdit];
+            [[NSApp keyWindow] makeFirstResponder: data->fieldEdit];
+        }
     }
-
-    [pool release];
 }
 
 void
@@ -655,11 +654,11 @@
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
 
     if (data && data->fieldEdit) {
-        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-        [data->fieldEdit removeFromSuperview];
-        [data->fieldEdit release];
-        data->fieldEdit = nil;
-        [pool release];
+        @autoreleasepool {
+            [data->fieldEdit removeFromSuperview];
+            [data->fieldEdit release];
+            data->fieldEdit = nil;
+        }
     }
 }
 
--- a/src/video/cocoa/SDL_cocoamessagebox.m	Fri Feb 01 17:09:01 2013 -0800
+++ b/src/video/cocoa/SDL_cocoamessagebox.m	Sun Jan 06 19:04:53 2013 +0300
@@ -39,41 +39,39 @@
 {
     Cocoa_RegisterApp();
 
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
-    NSAlert* alert = [[NSAlert alloc] init];
+    @autoreleasepool {
+        NSAlert* alert = [[NSAlert alloc] init];
 
-    if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) {
-        [alert setAlertStyle:NSCriticalAlertStyle];
-    } else if (messageboxdata->flags & SDL_MESSAGEBOX_WARNING) {
-        [alert setAlertStyle:NSWarningAlertStyle];
-    } else {
-        [alert setAlertStyle:NSInformationalAlertStyle];
-    }
+        if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) {
+            [alert setAlertStyle:NSCriticalAlertStyle];
+        } else if (messageboxdata->flags & SDL_MESSAGEBOX_WARNING) {
+            [alert setAlertStyle:NSWarningAlertStyle];
+        } else {
+            [alert setAlertStyle:NSInformationalAlertStyle];
+        }
 
-    [alert setMessageText:[NSString stringWithUTF8String:messageboxdata->title]];
-    [alert setInformativeText:[NSString stringWithUTF8String:messageboxdata->message]];
+        [alert setMessageText:[NSString stringWithUTF8String:messageboxdata->title]];
+        [alert setInformativeText:[NSString stringWithUTF8String:messageboxdata->message]];
 
-    const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
-    int i;
-    for (i = 0; i < messageboxdata->numbuttons; ++i) {
-        NSButton *button = [alert addButtonWithTitle:[[NSString alloc] initWithUTF8String:buttons[i].text]];
-        if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
-            [button setKeyEquivalent:@"\r"];
-        } else if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
-            [button setKeyEquivalent:@"\033"];
-        } else {
-            [button setKeyEquivalent:@""];
+        const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
+        int i;
+        for (i = 0; i < messageboxdata->numbuttons; ++i) {
+            NSButton *button = [alert addButtonWithTitle:[[NSString alloc] initWithUTF8String:buttons[i].text]];
+            if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
+                [button setKeyEquivalent:@"\r"];
+            } else if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
+                [button setKeyEquivalent:@"\033"];
+            } else {
+                [button setKeyEquivalent:@""];
+            }
         }
+
+        NSInteger clicked = [alert runModal];
+        clicked -= NSAlertFirstButtonReturn;
+        *buttonid = buttons[clicked].buttonid;
+        [alert release];
     }
 
-    NSInteger clicked = [alert runModal];
-    clicked -= NSAlertFirstButtonReturn;
-    *buttonid = buttons[clicked].buttonid;
-    [alert release];
-
-    [pool release];
-
     return 0;
 }
 
--- a/src/video/cocoa/SDL_cocoamouse.m	Fri Feb 01 17:09:01 2013 -0800
+++ b/src/video/cocoa/SDL_cocoamouse.m	Sun Jan 06 19:04:53 2013 +0300
@@ -32,140 +32,134 @@
 static SDL_Cursor *
 Cocoa_CreateDefaultCursor()
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    NSCursor *nscursor;
-    SDL_Cursor *cursor = NULL;
+    @autoreleasepool {
+        NSCursor *nscursor;
+        SDL_Cursor *cursor = NULL;
 
-    nscursor = [NSCursor arrowCursor];
+        nscursor = [NSCursor arrowCursor];
 
-    if (nscursor) {
-        cursor = SDL_calloc(1, sizeof(*cursor));
-        if (cursor) {
-            cursor->driverdata = nscursor;
-            [nscursor retain];
+        if (nscursor) {
+            cursor = SDL_calloc(1, sizeof(*cursor));
+            if (cursor) {
+                cursor->driverdata = nscursor;
+                [nscursor retain];
+            }
         }
+        
+        return cursor;
     }
-
-    [pool release];
-
-    return cursor;
 }
 
 static SDL_Cursor *
 Cocoa_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    NSImage *nsimage;
-    NSCursor *nscursor = NULL;
-    SDL_Cursor *cursor = NULL;
+    @autoreleasepool {
+        NSImage *nsimage;
+        NSCursor *nscursor = NULL;
+        SDL_Cursor *cursor = NULL;
 
-    nsimage = Cocoa_CreateImage(surface);
-    if (nsimage) {
-        nscursor = [[NSCursor alloc] initWithImage: nsimage hotSpot: NSMakePoint(hot_x, hot_y)];
-    }
+        nsimage = Cocoa_CreateImage(surface);
+        if (nsimage) {
+            nscursor = [[NSCursor alloc] initWithImage: nsimage hotSpot: NSMakePoint(hot_x, hot_y)];
+        }
 
-    if (nscursor) {
-        cursor = SDL_calloc(1, sizeof(*cursor));
-        if (cursor) {
-            cursor->driverdata = nscursor;
+        if (nscursor) {
+            cursor = SDL_calloc(1, sizeof(*cursor));
+            if (cursor) {
+                cursor->driverdata = nscursor;
+            }
         }
+        
+        return cursor;
     }
-
-    [pool release];
-
-    return cursor;
 }
 
 static SDL_Cursor *
 Cocoa_CreateSystemCursor(SDL_SystemCursor id)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    NSCursor *nscursor = NULL;
-    SDL_Cursor *cursor = NULL;
+    @autoreleasepool {
+        NSCursor *nscursor = NULL;
+        SDL_Cursor *cursor = NULL;
 
-    switch(id)
-    {
-    case SDL_SYSTEM_CURSOR_ARROW:
-        nscursor = [NSCursor arrowCursor];
-        break;
-    case SDL_SYSTEM_CURSOR_IBEAM:
-        nscursor = [NSCursor IBeamCursor];
-        break;
-    case SDL_SYSTEM_CURSOR_WAIT:
-        nscursor = [NSCursor arrowCursor];
-        break;
-    case SDL_SYSTEM_CURSOR_CROSSHAIR:
-        nscursor = [NSCursor crosshairCursor];
-        break;
-    case SDL_SYSTEM_CURSOR_WAITARROW:
-        nscursor = [NSCursor arrowCursor];
-        break;
-    case SDL_SYSTEM_CURSOR_SIZENWSE:
-    case SDL_SYSTEM_CURSOR_SIZENESW:
-        nscursor = [NSCursor closedHandCursor];
-        break;
-    case SDL_SYSTEM_CURSOR_SIZEWE:
-        nscursor = [NSCursor resizeLeftRightCursor];
-        break;
-    case SDL_SYSTEM_CURSOR_SIZENS:
-        nscursor = [NSCursor resizeUpDownCursor];
-        break;
-    case SDL_SYSTEM_CURSOR_SIZEALL:
-        nscursor = [NSCursor closedHandCursor];
-        break;
-    case SDL_SYSTEM_CURSOR_NO:
-        nscursor = [NSCursor operationNotAllowedCursor];
-        break;
-    case SDL_SYSTEM_CURSOR_HAND:
-        nscursor = [NSCursor pointingHandCursor];
-        break;
-    default:
-        SDL_assert(!"Unknown system cursor");
-        return NULL;
+        switch(id)
+        {
+        case SDL_SYSTEM_CURSOR_ARROW:
+            nscursor = [NSCursor arrowCursor];
+            break;
+        case SDL_SYSTEM_CURSOR_IBEAM:
+            nscursor = [NSCursor IBeamCursor];
+            break;
+        case SDL_SYSTEM_CURSOR_WAIT:
+            nscursor = [NSCursor arrowCursor];
+            break;
+        case SDL_SYSTEM_CURSOR_CROSSHAIR:
+            nscursor = [NSCursor crosshairCursor];
+            break;
+        case SDL_SYSTEM_CURSOR_WAITARROW:
+            nscursor = [NSCursor arrowCursor];
+            break;
+        case SDL_SYSTEM_CURSOR_SIZENWSE:
+        case SDL_SYSTEM_CURSOR_SIZENESW:
+            nscursor = [NSCursor closedHandCursor];
+            break;
+        case SDL_SYSTEM_CURSOR_SIZEWE:
+            nscursor = [NSCursor resizeLeftRightCursor];
+            break;
+        case SDL_SYSTEM_CURSOR_SIZENS:
+            nscursor = [NSCursor resizeUpDownCursor];
+            break;
+        case SDL_SYSTEM_CURSOR_SIZEALL:
+            nscursor = [NSCursor closedHandCursor];
+            break;
+        case SDL_SYSTEM_CURSOR_NO:
+            nscursor = [NSCursor operationNotAllowedCursor];
+            break;
+        case SDL_SYSTEM_CURSOR_HAND:
+            nscursor = [NSCursor pointingHandCursor];
+            break;
+        default:
+            SDL_assert(!"Unknown system cursor");
+            return NULL;
+        }
+
+        if (nscursor) {
+            cursor = SDL_calloc(1, sizeof(*cursor));
+            if (cursor) {
+                // We'll free it later, so retain it here
+                [nscursor retain];
+                cursor->driverdata = nscursor;
+            }
+        }
+            
+        return cursor;
     }
-
-    if (nscursor) {
-        cursor = SDL_calloc(1, sizeof(*cursor));
-        if (cursor) {
-            // We'll free it later, so retain it here
-            [nscursor retain];
-            cursor->driverdata = nscursor;
-        }
-    }
-
-    [pool release];
-
-    return cursor;
 }
 
 static void
 Cocoa_FreeCursor(SDL_Cursor * cursor)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    NSCursor *nscursor = (NSCursor *)cursor->driverdata;
+    @autoreleasepool {
+        NSCursor *nscursor = (NSCursor *)cursor->driverdata;
 
-    [nscursor release];
-    SDL_free(cursor);
-
-    [pool release];
+        [nscursor release];
+        SDL_free(cursor);
+    }
 }
 
 static int
 Cocoa_ShowCursor(SDL_Cursor * cursor)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
-    if (cursor) {
-        NSCursor *nscursor = (NSCursor *)cursor->driverdata;
+    @autoreleasepool {
+        if (cursor) {
+            NSCursor *nscursor = (NSCursor *)cursor->driverdata;
 
-        [nscursor set];
-        [NSCursor unhide];
-    } else {
-        [NSCursor hide];
+            [nscursor set];
+            [NSCursor unhide];
+        } else {
+            [NSCursor hide];
+        }
     }
 
-    [pool release];
-
     return 0;
 }
 
--- a/src/video/cocoa/SDL_cocoaopengl.m	Fri Feb 01 17:09:01 2013 -0800
+++ b/src/video/cocoa/SDL_cocoaopengl.m	Sun Jan 06 19:04:53 2013 +0300
@@ -80,7 +80,6 @@
     const int wantver = (_this->gl_config.major_version << 8) |
                         (_this->gl_config.minor_version);
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
-    NSAutoreleasePool *pool;
     SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
     SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
     NSOpenGLPixelFormatAttribute attr[32];
@@ -100,121 +99,116 @@
         return NULL;
     }
 
-    pool = [[NSAutoreleasePool alloc] init];
+    @autoreleasepool {
+        /* specify a profile if we're on Lion (10.7) or later. */
+        if (data->osversion >= 0x1070) {
+            NSOpenGLPixelFormatAttribute profile = kCGLOGLPVersion_Legacy;
+            if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) {
+                if (wantver == 0x0302) {
+                    profile = kCGLOGLPVersion_3_2_Core;
+                }
+            }
+            attr[i++] = kCGLPFAOpenGLProfile;
+            attr[i++] = profile;
+        }
+
+    #ifndef FULLSCREEN_TOGGLEABLE
+        if (window->flags & SDL_WINDOW_FULLSCREEN) {
+            attr[i++] = NSOpenGLPFAFullScreen;
+        }
+    #endif
+
+        attr[i++] = NSOpenGLPFAColorSize;
+        attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format)*8;
+
+        attr[i++] = NSOpenGLPFADepthSize;
+        attr[i++] = _this->gl_config.depth_size;
+
+        if (_this->gl_config.double_buffer) {
+            attr[i++] = NSOpenGLPFADoubleBuffer;
+        }
 
-    /* specify a profile if we're on Lion (10.7) or later. */
-    if (data->osversion >= 0x1070) {
-        NSOpenGLPixelFormatAttribute profile = kCGLOGLPVersion_Legacy;
-        if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) {
-            if (wantver == 0x0302) {
-                profile = kCGLOGLPVersion_3_2_Core;
+        if (_this->gl_config.stereo) {
+            attr[i++] = NSOpenGLPFAStereo;
+        }
+
+        if (_this->gl_config.stencil_size) {
+            attr[i++] = NSOpenGLPFAStencilSize;
+            attr[i++] = _this->gl_config.stencil_size;
+        }
+
+        if ((_this->gl_config.accum_red_size +
+             _this->gl_config.accum_green_size +
+             _this->gl_config.accum_blue_size +
+             _this->gl_config.accum_alpha_size) > 0) {
+            attr[i++] = NSOpenGLPFAAccumSize;
+            attr[i++] = _this->gl_config.accum_red_size + _this->gl_config.accum_green_size + _this->gl_config.accum_blue_size + _this->gl_config.accum_alpha_size;
+        }
+
+        if (_this->gl_config.multisamplebuffers) {
+            attr[i++] = NSOpenGLPFASampleBuffers;
+            attr[i++] = _this->gl_config.multisamplebuffers;
+        }
+
+        if (_this->gl_config.multisamplesamples) {
+            attr[i++] = NSOpenGLPFASamples;
+            attr[i++] = _this->gl_config.multisamplesamples;
+            attr[i++] = NSOpenGLPFANoRecovery;
+        }
+
+        if (_this->gl_config.accelerated >= 0) {
+            if (_this->gl_config.accelerated) {
+                attr[i++] = NSOpenGLPFAAccelerated;
+            } else {
+                attr[i++] = NSOpenGLPFARendererID;
+                attr[i++] = kCGLRendererGenericFloatID;
             }
         }
-        attr[i++] = kCGLPFAOpenGLProfile;
-        attr[i++] = profile;
-    }
 
-#ifndef FULLSCREEN_TOGGLEABLE
-    if (window->flags & SDL_WINDOW_FULLSCREEN) {
-        attr[i++] = NSOpenGLPFAFullScreen;
-    }
-#endif
+        attr[i++] = NSOpenGLPFAScreenMask;
+        attr[i++] = CGDisplayIDToOpenGLDisplayMask(displaydata->display);
+        attr[i] = 0;
 
-    attr[i++] = NSOpenGLPFAColorSize;
-    attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format)*8;
-
-    attr[i++] = NSOpenGLPFADepthSize;
-    attr[i++] = _this->gl_config.depth_size;
+        fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
+        if (fmt == nil) {
+            SDL_SetError ("Failed creating OpenGL pixel format");
+            return NULL;
+        }
 
-    if (_this->gl_config.double_buffer) {
-        attr[i++] = NSOpenGLPFADoubleBuffer;
-    }
+        context = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nil];
+
+        [fmt release];
 
-    if (_this->gl_config.stereo) {
-        attr[i++] = NSOpenGLPFAStereo;
-    }
+        if (context == nil) {
+            SDL_SetError ("Failed creating OpenGL context");
+            return NULL;
+        }
 
-    if (_this->gl_config.stencil_size) {
-        attr[i++] = NSOpenGLPFAStencilSize;
-        attr[i++] = _this->gl_config.stencil_size;
-    }
-
-    if ((_this->gl_config.accum_red_size +
-         _this->gl_config.accum_green_size +
-         _this->gl_config.accum_blue_size +
-         _this->gl_config.accum_alpha_size) > 0) {
-        attr[i++] = NSOpenGLPFAAccumSize;
-        attr[i++] = _this->gl_config.accum_red_size + _this->gl_config.accum_green_size + _this->gl_config.accum_blue_size + _this->gl_config.accum_alpha_size;
-    }
+        /*
+         * Wisdom from Apple engineer in reference to UT2003's OpenGL performance:
+         *  "You are blowing a couple of the internal OpenGL function caches. This
+         *  appears to be happening in the VAO case.  You can tell OpenGL to up
+         *  the cache size by issuing the following calls right after you create
+         *  the OpenGL context.  The default cache size is 16."    --ryan.
+         */
 
-    if (_this->gl_config.multisamplebuffers) {
-        attr[i++] = NSOpenGLPFASampleBuffers;
-        attr[i++] = _this->gl_config.multisamplebuffers;
-    }
+        #ifndef GLI_ARRAY_FUNC_CACHE_MAX
+        #define GLI_ARRAY_FUNC_CACHE_MAX 284
+        #endif
 
-    if (_this->gl_config.multisamplesamples) {
-        attr[i++] = NSOpenGLPFASamples;
-        attr[i++] = _this->gl_config.multisamplesamples;
-        attr[i++] = NSOpenGLPFANoRecovery;
-    }
+        #ifndef GLI_SUBMIT_FUNC_CACHE_MAX
+        #define GLI_SUBMIT_FUNC_CACHE_MAX 280
+        #endif
 
-    if (_this->gl_config.accelerated >= 0) {
-        if (_this->gl_config.accelerated) {
-            attr[i++] = NSOpenGLPFAAccelerated;
-        } else {
-            attr[i++] = NSOpenGLPFARendererID;
-            attr[i++] = kCGLRendererGenericFloatID;
+        {
+            GLint cache_max = 64;
+            CGLContextObj ctx = [context CGLContextObj];
+            CGLSetParameter (ctx, GLI_SUBMIT_FUNC_CACHE_MAX, &cache_max);
+            CGLSetParameter (ctx, GLI_ARRAY_FUNC_CACHE_MAX, &cache_max);
         }
     }
-
-    attr[i++] = NSOpenGLPFAScreenMask;
-    attr[i++] = CGDisplayIDToOpenGLDisplayMask(displaydata->display);
-    attr[i] = 0;
-
-    fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
-    if (fmt == nil) {
-        SDL_SetError ("Failed creating OpenGL pixel format");
-        [pool release];
-        return NULL;
-    }
-
-    context = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nil];
-
-    [fmt release];
-
-    if (context == nil) {
-        SDL_SetError ("Failed creating OpenGL context");
-        [pool release];
-        return NULL;
-    }
-
-    /*
-     * Wisdom from Apple engineer in reference to UT2003's OpenGL performance:
-     *  "You are blowing a couple of the internal OpenGL function caches. This
-     *  appears to be happening in the VAO case.  You can tell OpenGL to up
-     *  the cache size by issuing the following calls right after you create
-     *  the OpenGL context.  The default cache size is 16."    --ryan.
-     */
-
-    #ifndef GLI_ARRAY_FUNC_CACHE_MAX
-    #define GLI_ARRAY_FUNC_CACHE_MAX 284
-    #endif
-
-    #ifndef GLI_SUBMIT_FUNC_CACHE_MAX
-    #define GLI_SUBMIT_FUNC_CACHE_MAX 280
-    #endif
-
-    {
-        GLint cache_max = 64;
-        CGLContextObj ctx = [context CGLContextObj];
-        CGLSetParameter (ctx, GLI_SUBMIT_FUNC_CACHE_MAX, &cache_max);
-        CGLSetParameter (ctx, GLI_ARRAY_FUNC_CACHE_MAX, &cache_max);
-    }
-
     /* End Wisdom from Apple Engineer section. --ryan. */
 
-    [pool release];
-
     if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) {
         Cocoa_GL_DeleteContext(_this, context);
         return NULL;
@@ -226,107 +220,94 @@
 int
 Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
 {
-    NSAutoreleasePool *pool;
-
-    pool = [[NSAutoreleasePool alloc] init];
-
-    if (context) {
-        SDL_WindowData *windowdata = (SDL_WindowData *)window->driverdata;
-        NSOpenGLContext *nscontext = (NSOpenGLContext *)context;
+    @autoreleasepool {
+        if (context) {
+            SDL_WindowData *windowdata = (SDL_WindowData *)window->driverdata;
+            NSOpenGLContext *nscontext = (NSOpenGLContext *)context;
 
-        if (window->flags & SDL_WINDOW_SHOWN) {
-#ifndef FULLSCREEN_TOGGLEABLE
-            if (window->flags & SDL_WINDOW_FULLSCREEN) {
-                [nscontext setFullScreen];
-            } else
-#endif
-            {
-                [nscontext setView:[windowdata->nswindow contentView]];
-                [nscontext update];
+            if (window->flags & SDL_WINDOW_SHOWN) {
+    #ifndef FULLSCREEN_TOGGLEABLE
+                if (window->flags & SDL_WINDOW_FULLSCREEN) {
+                    [nscontext setFullScreen];
+                } else
+    #endif
+                {
+                    [nscontext setView:[windowdata->nswindow contentView]];
+                    [nscontext update];
+                }
             }
+            [nscontext makeCurrentContext];
+        } else {
+            [NSOpenGLContext clearCurrentContext];
         }
-        [nscontext makeCurrentContext];
-    } else {
-        [NSOpenGLContext clearCurrentContext];
     }
 
-    [pool release];
     return 0;
 }
 
 int
 Cocoa_GL_SetSwapInterval(_THIS, int interval)
 {
-    NSAutoreleasePool *pool;
     NSOpenGLContext *nscontext;
     GLint value;
     int status;
 
-    pool = [[NSAutoreleasePool alloc] init];
-
-    nscontext = [NSOpenGLContext currentContext];
-    if (nscontext != nil) {
-        value = interval;
-        [nscontext setValues:&value forParameter:NSOpenGLCPSwapInterval];
-        status = 0;
-    } else {
-        SDL_SetError("No current OpenGL context");
-        status = -1;
+    @autoreleasepool {
+        nscontext = [NSOpenGLContext currentContext];
+        if (nscontext != nil) {
+            value = interval;
+            [nscontext setValues:&value forParameter:NSOpenGLCPSwapInterval];
+            status = 0;
+        } else {
+            SDL_SetError("No current OpenGL context");
+            status = -1;
+        }
     }
 
-    [pool release];
     return status;
 }
 
 int
 Cocoa_GL_GetSwapInterval(_THIS)
 {
-    NSAutoreleasePool *pool;
     NSOpenGLContext *nscontext;
     GLint value;
     int status = 0;
 
-    pool = [[NSAutoreleasePool alloc] init];
-
-    nscontext = [NSOpenGLContext currentContext];
-    if (nscontext != nil) {
-        [nscontext getValues:&value forParameter:NSOpenGLCPSwapInterval];
-        status = (int)value;
+    @autoreleasepool {
+        nscontext = [NSOpenGLContext currentContext];
+        if (nscontext != nil) {
+            [nscontext getValues:&value forParameter:NSOpenGLCPSwapInterval];
+            status = (int)value;
+        }
     }
 
-    [pool release];
     return status;
 }
 
 void
 Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
 {
-    NSAutoreleasePool *pool;
     NSOpenGLContext *nscontext;
 
-    pool = [[NSAutoreleasePool alloc] init];
-
-    /* FIXME: Do we need to get the context for the window? */
-    nscontext = [NSOpenGLContext currentContext];
-    if (nscontext != nil) {
-        [nscontext flushBuffer];
+    @autoreleasepool {
+        /* FIXME: Do we need to get the context for the window? */
+        nscontext = [NSOpenGLContext currentContext];
+        if (nscontext != nil) {
+            [nscontext flushBuffer];
+        }
     }
-
-    [pool release];
 }
 
 void
 Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context)
 {
-    NSAutoreleasePool *pool;
     NSOpenGLContext *nscontext = (NSOpenGLContext *)context;
 
-    pool = [[NSAutoreleasePool alloc] init];
-
-    [nscontext clearDrawable];
-    [nscontext release];
-
-    [pool release];
+    @autoreleasepool {
+        [nscontext clearDrawable];
+        [nscontext release];
+    }
 }
 
 #endif /* SDL_VIDEO_OPENGL_CGL */
--- a/src/video/cocoa/SDL_cocoashape.m	Fri Feb 01 17:09:01 2013 -0800
+++ b/src/video/cocoa/SDL_cocoashape.m	Sun Jan 06 19:04:53 2013 +0300
@@ -74,7 +74,7 @@
     SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata;
 	SDL_WindowData* windata = (SDL_WindowData*)shaper->window->driverdata;
 	SDL_CocoaClosure closure;
-	NSAutoreleasePool *pool = NULL;
+
     if(data->saved == SDL_TRUE) {
         [data->context restoreGraphicsState];
         data->saved = SDL_FALSE;
@@ -88,12 +88,13 @@
     NSRectFill([[windata->nswindow contentView] frame]);
     data->shape = SDL_CalculateShapeTree(*shape_mode,shape);
 	
-	pool = [[NSAutoreleasePool alloc] init];
-    closure.view = [windata->nswindow contentView];
-    closure.path = [[NSBezierPath bezierPath] autorelease];
-	closure.window = shaper->window;
-    SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
-    [closure.path addClip];
+    @autoreleasepool {
+        closure.view = [windata->nswindow contentView];
+        closure.path = [[NSBezierPath bezierPath] autorelease];
+        closure.window = shaper->window;
+        SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
+        [closure.path addClip];
+    }
 
     return 0;
 }
--- a/src/video/cocoa/SDL_cocoavideo.m	Fri Feb 01 17:09:01 2013 -0800
+++ b/src/video/cocoa/SDL_cocoavideo.m	Sun Jan 06 19:04:53 2013 +0300
@@ -250,37 +250,36 @@
         }
     }
 
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    @autoreleasepool {
+        NSString *msg = [NSString stringWithFormat:
+                @"Assertion failure at %s (%s:%d), triggered %u time%s:\n  '%s'",
+                    data->function, data->filename, data->linenum,
+                    data->trigger_count, (data->trigger_count == 1) ? "" : "s",
+                    data->condition];
 
-    NSString *msg = [NSString stringWithFormat:
-            @"Assertion failure at %s (%s:%d), triggered %u time%s:\n  '%s'",
-                data->function, data->filename, data->linenum,
-                data->trigger_count, (data->trigger_count == 1) ? "" : "s",
-                data->condition];
+        NSLog(@"%@", msg);
 
-    NSLog(@"%@", msg);
-
-    /*
-     * !!! FIXME: this code needs to deal with fullscreen modes:
-     * !!! FIXME:  reset to default desktop, runModal, reset to current?
-     */
+        /*
+         * !!! FIXME: this code needs to deal with fullscreen modes:
+         * !!! FIXME:  reset to default desktop, runModal, reset to current?
+         */
 
-    NSAlert* alert = [[NSAlert alloc] init];
-    [alert setAlertStyle:NSCriticalAlertStyle];
-    [alert setMessageText:msg];
-    [alert addButtonWithTitle:@"Retry"];
-    [alert addButtonWithTitle:@"Break"];
-    [alert addButtonWithTitle:@"Abort"];
-    [alert addButtonWithTitle:@"Ignore"];
-    [alert addButtonWithTitle:@"Always Ignore"];
-    const NSInteger clicked = [alert runModal];
-    [pool release];
+        NSAlert* alert = [[NSAlert alloc] init];
+        [alert setAlertStyle:NSCriticalAlertStyle];
+        [alert setMessageText:msg];
+        [alert addButtonWithTitle:@"Retry"];
+        [alert addButtonWithTitle:@"Break"];
+        [alert addButtonWithTitle:@"Abort"];
+        [alert addButtonWithTitle:@"Ignore"];
+        [alert addButtonWithTitle:@"Always Ignore"];
+        const NSInteger clicked = [alert runModal];
 
-    if (!initialized) {
-        SDL_QuitSubSystem(SDL_INIT_VIDEO);
+        if (!initialized) {
+            SDL_QuitSubSystem(SDL_INIT_VIDEO);
+        }
+
+        return (SDL_assert_state) (clicked - NSAlertFirstButtonReturn);
     }
-
-    return (SDL_assert_state) (clicked - NSAlertFirstButtonReturn);
 }
 
 #endif /* SDL_VIDEO_DRIVER_COCOA */
--- a/src/video/cocoa/SDL_cocoawindow.m	Fri Feb 01 17:09:01 2013 -0800
+++ b/src/video/cocoa/SDL_cocoawindow.m	Sun Jan 06 19:04:53 2013 +0300
@@ -507,7 +507,6 @@
 static int
 SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
 {
-    NSAutoreleasePool *pool;
     SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
     SDL_WindowData *data;
 
@@ -522,313 +521,297 @@
     data->created = created;
     data->videodata = videodata;
 
-    pool = [[NSAutoreleasePool alloc] init];
-
-    /* Create an event listener for the window */
-    data->listener = [[Cocoa_WindowListener alloc] init];
+    @autoreleasepool {
+        /* Create an event listener for the window */
+        data->listener = [[Cocoa_WindowListener alloc] init];
 
-    /* Fill in the SDL window with the window data */
-    {
-        NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
-        ConvertNSRect(&rect);
-        window->x = (int)rect.origin.x;
-        window->y = (int)rect.origin.y;
-        window->w = (int)rect.size.width;
-        window->h = (int)rect.size.height;
-    }
+        /* Fill in the SDL window with the window data */
+        {
+            NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
+            ConvertNSRect(&rect);
+            window->x = (int)rect.origin.x;
+            window->y = (int)rect.origin.y;
+            window->w = (int)rect.size.width;
+            window->h = (int)rect.size.height;
+        }
 
-    /* Set up the listener after we create the view */
-    [data->listener listen:data];
+        /* Set up the listener after we create the view */
+        [data->listener listen:data];
 
-    if ([nswindow isVisible]) {
-        window->flags |= SDL_WINDOW_SHOWN;
-    } else {
-        window->flags &= ~SDL_WINDOW_SHOWN;
-    }
-    {
-        unsigned int style = [nswindow styleMask];
-
-        if (style == NSBorderlessWindowMask) {
-            window->flags |= SDL_WINDOW_BORDERLESS;
+        if ([nswindow isVisible]) {
+            window->flags |= SDL_WINDOW_SHOWN;
         } else {
-            window->flags &= ~SDL_WINDOW_BORDERLESS;
+            window->flags &= ~SDL_WINDOW_SHOWN;
         }
-        if (style & NSResizableWindowMask) {
-            window->flags |= SDL_WINDOW_RESIZABLE;
-        } else {
-            window->flags &= ~SDL_WINDOW_RESIZABLE;
+        {
+            unsigned int style = [nswindow styleMask];
+
+            if (style == NSBorderlessWindowMask) {
+                window->flags |= SDL_WINDOW_BORDERLESS;
+            } else {
+                window->flags &= ~SDL_WINDOW_BORDERLESS;
+            }
+            if (style & NSResizableWindowMask) {
+                window->flags |= SDL_WINDOW_RESIZABLE;
+            } else {
+                window->flags &= ~SDL_WINDOW_RESIZABLE;
+            }
         }
-    }
-    /* isZoomed always returns true if the window is not resizable */
-    if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) {
-        window->flags |= SDL_WINDOW_MAXIMIZED;
-    } else {
-        window->flags &= ~SDL_WINDOW_MAXIMIZED;
+        /* isZoomed always returns true if the window is not resizable */
+        if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) {
+            window->flags |= SDL_WINDOW_MAXIMIZED;
+        } else {
+            window->flags &= ~SDL_WINDOW_MAXIMIZED;
+        }
+        if ([nswindow isMiniaturized]) {
+            window->flags |= SDL_WINDOW_MINIMIZED;
+        } else {
+            window->flags &= ~SDL_WINDOW_MINIMIZED;
+        }
+        if ([nswindow isKeyWindow]) {
+            window->flags |= SDL_WINDOW_INPUT_FOCUS;
+            SDL_SetKeyboardFocus(data->window);
+        }
+
+        /* All done! */
+        window->driverdata = data;
+        return 0;
     }
-    if ([nswindow isMiniaturized]) {
-        window->flags |= SDL_WINDOW_MINIMIZED;
-    } else {
-        window->flags &= ~SDL_WINDOW_MINIMIZED;
-    }
-    if ([nswindow isKeyWindow]) {
-        window->flags |= SDL_WINDOW_INPUT_FOCUS;
-        SDL_SetKeyboardFocus(data->window);
-    }
-
-    /* All done! */
-    [pool release];
-    window->driverdata = data;
-    return 0;
 }
 
 int
 Cocoa_CreateWindow(_THIS, SDL_Window * window)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    NSWindow *nswindow;
-    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
-    NSRect rect;
-    SDL_Rect bounds;
-    unsigned int style;
+    @autoreleasepool {
+        NSWindow *nswindow;
+        SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
+        NSRect rect;
+        SDL_Rect bounds;
+        unsigned int style;
 
-    Cocoa_GetDisplayBounds(_this, display, &bounds);
-    rect.origin.x = window->x;
-    rect.origin.y = window->y;
-    rect.size.width = window->w;
-    rect.size.height = window->h;
-    ConvertNSRect(&rect);
+        Cocoa_GetDisplayBounds(_this, display, &bounds);
+        rect.origin.x = window->x;
+        rect.origin.y = window->y;
+        rect.size.width = window->w;
+        rect.size.height = window->h;
+        ConvertNSRect(&rect);
 
-    style = GetWindowStyle(window);
+        style = GetWindowStyle(window);
 
-    /* Figure out which screen to place this window */
-    NSArray *screens = [NSScreen screens];
-    NSScreen *screen = nil;
-    NSScreen *candidate;
-    int i, count = [screens count];
-    for (i = 0; i < count; ++i) {
-        candidate = [screens objectAtIndex:i];
-        NSRect screenRect = [candidate frame];
-        if (rect.origin.x >= screenRect.origin.x &&
-            rect.origin.x < screenRect.origin.x + screenRect.size.width &&
-            rect.origin.y >= screenRect.origin.y &&
-            rect.origin.y < screenRect.origin.y + screenRect.size.height) {
-            screen = candidate;
-            rect.origin.x -= screenRect.origin.x;
-            rect.origin.y -= screenRect.origin.y;
+        /* Figure out which screen to place this window */
+        NSArray *screens = [NSScreen screens];
+        NSScreen *screen = nil;
+        NSScreen *candidate;
+        int i, count = [screens count];
+        for (i = 0; i < count; ++i) {
+            candidate = [screens objectAtIndex:i];
+            NSRect screenRect = [candidate frame];
+            if (rect.origin.x >= screenRect.origin.x &&
+                rect.origin.x < screenRect.origin.x + screenRect.size.width &&
+                rect.origin.y >= screenRect.origin.y &&
+                rect.origin.y < screenRect.origin.y + screenRect.size.height) {
+                screen = candidate;
+                rect.origin.x -= screenRect.origin.x;
+                rect.origin.y -= screenRect.origin.y;
+            }
         }
-    }
-    nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:YES screen:screen];
+        nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:YES screen:screen];
 
-    // Create a default view for this window
-    rect = [nswindow contentRectForFrameRect:[nswindow frame]];
-    NSView *contentView = [[SDLView alloc] initWithFrame:rect];
-    [nswindow setContentView: contentView];
-    [contentView release];
+        // Create a default view for this window
+        rect = [nswindow contentRectForFrameRect:[nswindow frame]];
+        NSView *contentView = [[SDLView alloc] initWithFrame:rect];
+        [nswindow setContentView: contentView];
+        [contentView release];
 
-    [pool release];
-
-    if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {
-        [nswindow release];
-        return -1;
+        if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {
+            [nswindow release];
+            return -1;
+        }
+        return 0;
     }
-    return 0;
 }
 
 int
 Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
 {
-    NSAutoreleasePool *pool;
     NSWindow *nswindow = (NSWindow *) data;
     NSString *title;
 
-    pool = [[NSAutoreleasePool alloc] init];
-
-    /* Query the title from the existing window */
-    title = [nswindow title];
-    if (title) {
-        window->title = SDL_strdup([title UTF8String]);
+    @autoreleasepool {
+        /* Query the title from the existing window */
+        title = [nswindow title];
+        if (title) {
+            window->title = SDL_strdup([title UTF8String]);
+        }
     }
 
-    [pool release];
-
     return SetupWindowData(_this, window, nswindow, SDL_FALSE);
 }
 
 void
 Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
-    NSString *string;
+    @autoreleasepool {
+        NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
+        NSString *string;
 
-    if(window->title) {
-        string = [[NSString alloc] initWithUTF8String:window->title];
-    } else {
-        string = [[NSString alloc] init];
+        if(window->title) {
+            string = [[NSString alloc] initWithUTF8String:window->title];
+        } else {
+            string = [[NSString alloc] init];
+        }
+        [nswindow setTitle:string];
+        [string release];
     }
-    [nswindow setTitle:string];
-    [string release];
-
-    [pool release];
 }
 
 void
 Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    NSImage *nsimage = Cocoa_CreateImage(icon);
+    @autoreleasepool {
+        NSImage *nsimage = Cocoa_CreateImage(icon);
 
-    if (nsimage) {
-        [NSApp setApplicationIconImage:nsimage];
+        if (nsimage) {
+            [NSApp setApplicationIconImage:nsimage];
+        }
     }
-
-    [pool release];
 }
 
 void
 Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
-    NSRect rect;
-    Uint32 moveHack;
-
-    rect.origin.x = window->x;
-    rect.origin.y = window->y;
-    rect.size.width = window->w;
-    rect.size.height = window->h;
-    ConvertNSRect(&rect);
+    @autoreleasepool {
+        NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
+        NSRect rect;
+        Uint32 moveHack;
 
-    moveHack = s_moveHack;
-    s_moveHack = 0;
-    [nswindow setFrameOrigin:rect.origin];
-    s_moveHack = moveHack;
+        rect.origin.x = window->x;
+        rect.origin.y = window->y;
+        rect.size.width = window->w;
+        rect.size.height = window->h;
+        ConvertNSRect(&rect);
 
-    if (window == _this->current_glwin) {
-        [((NSOpenGLContext *) _this->current_glctx) update];
+        moveHack = s_moveHack;
+        s_moveHack = 0;
+        [nswindow setFrameOrigin:rect.origin];
+        s_moveHack = moveHack;
+
+        if (window == _this->current_glwin) {
+            [((NSOpenGLContext *) _this->current_glctx) update];
+        }
     }
-
-    [pool release];
 }
 
 void
 Cocoa_SetWindowSize(_THIS, SDL_Window * window)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
-    NSWindow *nswindow = windata->nswindow;
-    NSSize size;
+    @autoreleasepool {
+        SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
+        NSWindow *nswindow = windata->nswindow;
+        NSSize size;
 
-    size.width = window->w;
-    size.height = window->h;
-    [nswindow setContentSize:size];
+        size.width = window->w;
+        size.height = window->h;
+        [nswindow setContentSize:size];
 
-    if (window == _this->current_glwin) {
-        [((NSOpenGLContext *) _this->current_glctx) update];
+        if (window == _this->current_glwin) {
+            [((NSOpenGLContext *) _this->current_glctx) update];
+        }
     }
-
-    [pool release];
 }
 
 void
 Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
-        
-    NSSize minSize;
-    minSize.width = window->min_w;
-    minSize.height = window->min_h;
-        
-    [windata->nswindow setContentMinSize:minSize];
-    
-    [pool release];
+    @autoreleasepool {
+        SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
+            
+        NSSize minSize;
+        minSize.width = window->min_w;
+        minSize.height = window->min_h;
+            
+        [windata->nswindow setContentMinSize:minSize];
+    }
 }
 
 void
 Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
-        
-    NSSize maxSize;
-    maxSize.width = window->max_w;
-    maxSize.height = window->max_h;
-        
-    [windata->nswindow setContentMaxSize:maxSize];
-    
-    [pool release];
+    @autoreleasepool {
+        SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
+            
+        NSSize maxSize;
+        maxSize.width = window->max_w;
+        maxSize.height = window->max_h;
+            
+        [windata->nswindow setContentMaxSize:maxSize];
+    }
 }
 
 void
 Cocoa_ShowWindow(_THIS, SDL_Window * window)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
+    @autoreleasepool {
+        NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
 
-    if (![nswindow isMiniaturized]) {
-        [nswindow makeKeyAndOrderFront:nil];
+        if (![nswindow isMiniaturized]) {
+            [nswindow makeKeyAndOrderFront:nil];
+        }
     }
-    [pool release];
 }
 
 void
 Cocoa_HideWindow(_THIS, SDL_Window * window)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
-
-    [nswindow orderOut:nil];
-    [pool release];
+    @autoreleasepool {
+        NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
+        [nswindow orderOut:nil];
+    }
 }
 
 void
 Cocoa_RaiseWindow(_THIS, SDL_Window * window)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
-
-    [nswindow makeKeyAndOrderFront:nil];
-    [pool release];
+    @autoreleasepool {
+        NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
+        [nswindow makeKeyAndOrderFront:nil];
+    }
 }
 
 void
 Cocoa_MaximizeWindow(_THIS, SDL_Window * window)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
-
-    [nswindow zoom:nil];
+    @autoreleasepool {
+        NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
+        [nswindow zoom:nil];
 
-    if (window == _this->current_glwin) {
-        [((NSOpenGLContext *) _this->current_glctx) update];
+        if (window == _this->current_glwin) {
+            [((NSOpenGLContext *) _this->current_glctx) update];
+        }
     }
-
-    [pool release];
 }
 
 void
 Cocoa_MinimizeWindow(_THIS, SDL_Window * window)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
-
-    [nswindow miniaturize:nil];
-    [pool release];
+    @autoreleasepool {
+        NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
+        [nswindow miniaturize:nil];
+    }
 }
 
 void
 Cocoa_RestoreWindow(_THIS, SDL_Window * window)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
+    @autoreleasepool {
+        NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
 
-    if ([nswindow isMiniaturized]) {
-        [nswindow deminiaturize:nil];
-    } else if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) {
-        [nswindow zoom:nil];
+        if ([nswindow isMiniaturized]) {
+            [nswindow deminiaturize:nil];
+        } else if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) {
+            [nswindow zoom:nil];
+        }
     }
-    [pool release];
 }
 
 static NSWindow *
@@ -854,96 +837,95 @@
 {
     /* this message arrived in 10.6. You're out of luck on older OSes. */
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
-    if ([nswindow respondsToSelector:@selector(setStyleMask:)]) {
-        [nswindow setStyleMask:GetWindowStyle(window)];
-        if (bordered) {
-            Cocoa_SetWindowTitle(_this, window);  // this got blanked out.
+    @autoreleasepool {
+        NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
+        if ([nswindow respondsToSelector:@selector(setStyleMask:)]) {
+            [nswindow setStyleMask:GetWindowStyle(window)];
+            if (bordered) {
+                Cocoa_SetWindowTitle(_this, window);  // this got blanked out.
+            }
         }
     }
-    [pool release];
 #endif
 }
 
 void
 Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
-    NSWindow *nswindow = data->nswindow;
-    NSRect rect;
-
-    /* The view responder chain gets messed with during setStyleMask */
-    if ([[nswindow contentView] nextResponder] == data->listener) {
-        [[nswindow contentView] setNextResponder:nil];
-    }
+    @autoreleasepool {
+        SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
+        NSWindow *nswindow = data->nswindow;
+        NSRect rect;
 
-    if (fullscreen) {
-        SDL_Rect bounds;
-
-        Cocoa_GetDisplayBounds(_this, display, &bounds);
-        rect.origin.x = bounds.x;
-        rect.origin.y = bounds.y;
-        rect.size.width = bounds.w;
-        rect.size.height = bounds.h;
-        ConvertNSRect(&rect);
-
-        /* Hack to fix origin on Mac OS X 10.4 */
-        NSRect screenRect = [[nswindow screen] frame];
-        if (screenRect.size.height >= 1.0f) {
-            rect.origin.y += (screenRect.size.height - rect.size.height);
+        /* The view responder chain gets messed with during setStyleMask */
+        if ([[nswindow contentView] nextResponder] == data->listener) {
+            [[nswindow contentView] setNextResponder:nil];
         }
 
-        if ([nswindow respondsToSelector: @selector(setStyleMask:)]) {
-            [nswindow performSelector: @selector(setStyleMask:) withObject: (id)NSBorderlessWindowMask];
+        if (fullscreen) {
+            SDL_Rect bounds;
+
+            Cocoa_GetDisplayBounds(_this, display, &bounds);
+            rect.origin.x = bounds.x;
+            rect.origin.y = bounds.y;
+            rect.size.width = bounds.w;
+            rect.size.height = bounds.h;
+            ConvertNSRect(&rect);
+
+            /* Hack to fix origin on Mac OS X 10.4 */
+            NSRect screenRect = [[nswindow screen] frame];
+            if (screenRect.size.height >= 1.0f) {
+                rect.origin.y += (screenRect.size.height - rect.size.height);
+            }
+
+            if ([nswindow respondsToSelector: @selector(setStyleMask:)]) {
+                [nswindow performSelector: @selector(setStyleMask:) withObject: (id)NSBorderlessWindowMask];
+            } else {
+                nswindow = Cocoa_RebuildWindow(data, nswindow, NSBorderlessWindowMask);
+            }
         } else {
-            nswindow = Cocoa_RebuildWindow(data, nswindow, NSBorderlessWindowMask);
+            rect.origin.x = window->windowed.x;
+            rect.origin.y = window->windowed.y;
+            rect.size.width = window->windowed.w;
+            rect.size.height = window->windowed.h;
+            ConvertNSRect(&rect);
+
+            if ([nswindow respondsToSelector: @selector(setStyleMask:)]) {
+                [nswindow performSelector: @selector(setStyleMask:) withObject: (id)(uintptr_t)GetWindowStyle(window)];
+            } else {
+                nswindow = Cocoa_RebuildWindow(data, nswindow, GetWindowStyle(window));
+            }
         }
-    } else {
-        rect.origin.x = window->windowed.x;
-        rect.origin.y = window->windowed.y;
-        rect.size.width = window->windowed.w;
-        rect.size.height = window->windowed.h;
-        ConvertNSRect(&rect);
+
+        /* The view responder chain gets messed with during setStyleMask */
+        if ([[nswindow contentView] nextResponder] != data->listener) {
+            [[nswindow contentView] setNextResponder:data->listener];
+        }
+
+        s_moveHack = 0;
+        [nswindow setFrameOrigin:rect.origin];
+        [nswindow setContentSize:rect.size];
+        s_moveHack = SDL_GetTicks();
 
-        if ([nswindow respondsToSelector: @selector(setStyleMask:)]) {
-            [nswindow performSelector: @selector(setStyleMask:) withObject: (id)(uintptr_t)GetWindowStyle(window)];
+        /* When the window style changes the title is cleared */
+        if (!fullscreen) {
+            Cocoa_SetWindowTitle(_this, window);
+        }
+
+    #ifdef FULLSCREEN_TOGGLEABLE
+        if (SDL_ShouldAllowTopmost() && fullscreen) {
+            /* OpenGL is rendering to the window, so make it visible! */
+            [nswindow setLevel:CGShieldingWindowLevel()];
         } else {
-            nswindow = Cocoa_RebuildWindow(data, nswindow, GetWindowStyle(window));
+            [nswindow setLevel:kCGNormalWindowLevel];
+        }
+    #endif
+        [nswindow makeKeyAndOrderFront:nil];
+
+        if (window == _this->current_glwin) {
+            [((NSOpenGLContext *) _this->current_glctx) update];
         }
     }
-
-    /* The view responder chain gets messed with during setStyleMask */
-    if ([[nswindow contentView] nextResponder] != data->listener) {
-        [[nswindow contentView] setNextResponder:data->listener];
-    }
-
-    s_moveHack = 0;
-    [nswindow setFrameOrigin:rect.origin];
-    [nswindow setContentSize:rect.size];
-    s_moveHack = SDL_GetTicks();
-
-    /* When the window style changes the title is cleared */
-    if (!fullscreen) {
-        Cocoa_SetWindowTitle(_this, window);
-    }
-
-#ifdef FULLSCREEN_TOGGLEABLE
-    if (SDL_ShouldAllowTopmost() && fullscreen) {
-        /* OpenGL is rendering to the window, so make it visible! */
-        [nswindow setLevel:CGShieldingWindowLevel()];
-    } else {
-        [nswindow setLevel:kCGNormalWindowLevel];
-    }
-#endif
-    [nswindow makeKeyAndOrderFront:nil];
-
-    if (window == _this->current_glwin) {
-        [((NSOpenGLContext *) _this->current_glctx) update];
-    }
-
-    [pool release];
 }
 
 int
@@ -1027,18 +1009,18 @@
 void
 Cocoa_DestroyWindow(_THIS, SDL_Window * window)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
+    @autoreleasepool {
+        SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
 
-    if (data) {
-        [data->listener close];
-        [data->listener release];
-        if (data->created) {
-            [data->nswindow close];
+        if (data) {
+            [data->listener close];
+            [data->listener release];
+            if (data->created) {
+                [data->nswindow close];
+            }
+            SDL_free(data);
         }
-        SDL_free(data);
     }
-    [pool release];
 }
 
 SDL_bool
--- a/test/automated/rwops/TestSupportRWops_Cocoa.m	Fri Feb 01 17:09:01 2013 -0800
+++ b/test/automated/rwops/TestSupportRWops_Cocoa.m	Sun Jan 06 19:04:53 2013 +0300
@@ -21,30 +21,23 @@
     FILE* fp = NULL;
 
 	// If the file mode is writable, skip all the bundle stuff because generally the bundle is read-only.
-	if(strcmp("r", mode) && strcmp("rb", mode))
-	{
+	if (strcmp("r", mode) && strcmp("rb", mode)) {
 		return fopen(file, mode);
 	}
 	
-	NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
-
+	@autoreleasepool {
+        NSFileManager* file_manager = [NSFileManager defaultManager];
+        NSString* resource_path = [[NSBundle mainBundle] resourcePath];
 
-	NSFileManager* file_manager = [NSFileManager defaultManager];
-	NSString* resource_path = [[NSBundle mainBundle] resourcePath];
-
-	NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
+        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;
 }
@@ -53,16 +46,14 @@
 {
     FILE* fp = NULL;
 	
-	NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
-	
-	NSFileManager* file_manager = [NSFileManager defaultManager];
-	NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
-	NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component];
+	@autoreleasepool {
+        NSFileManager* file_manager = [NSFileManager defaultManager];
+        NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
+        NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component];
 
-	fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
-	
-	[autorelease_pool drain];
-	
+        fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
+    }
+    
 	return fp;
 }
 
@@ -75,15 +66,14 @@
 {
 	SDL_RWops* rw = NULL;
 
-	NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
-	
-	NSFileManager* file_manager = [NSFileManager defaultManager];
-	NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
-	NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component];
-	
-	rw = SDL_RWFromFile( [full_path_with_file_to_try fileSystemRepresentation], mode );
-
-	[autorelease_pool drain];
+	@autoreleasepool {
+        NSFileManager* file_manager = [NSFileManager defaultManager];
+        NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
+        NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component];
+        
+        rw = SDL_RWFromFile( [full_path_with_file_to_try fileSystemRepresentation], mode );
+    }
+    
 	return rw;
 }