Fixed 2584 - Memory leak in Cocoa_GetDisplayName
authorSam Lantinga <slouken@libsdl.org>
Sun, 15 Jun 2014 17:18:05 -0700
changeset 8866 49562091afe1
parent 8865 105bbdd3183d
child 8867 540acbf32d5b
Fixed 2584 - Memory leak in Cocoa_GetDisplayName Diego The Xcode Instruments Leak tool reports a leak from IODisplayCreateInfoDictionary in Cocoa_GetDisplayName. This happened after upgrading to Xcode 5.
src/video/cocoa/SDL_cocoamodes.m
--- a/src/video/cocoa/SDL_cocoamodes.m	Sun Jun 15 13:05:30 2014 -0700
+++ b/src/video/cocoa/SDL_cocoamodes.m	Sun Jun 15 17:18:05 2014 -0700
@@ -200,14 +200,14 @@
 static const char *
 Cocoa_GetDisplayName(CGDirectDisplayID displayID)
 {
-    NSDictionary *deviceInfo = (NSDictionary *)IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID), kIODisplayOnlyPreferredName);
-    NSDictionary *localizedNames = [deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]];
+    CFDictionaryRef deviceInfo = IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID), kIODisplayOnlyPreferredName);
+    NSDictionary *localizedNames = [(NSDictionary *)deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]];
     const char* displayName = NULL;
 
     if ([localizedNames count] > 0) {
         displayName = SDL_strdup([[localizedNames objectForKey:[[localizedNames allKeys] objectAtIndex:0]] UTF8String]);
     }
-    [deviceInfo release];
+    CFRelease(deviceInfo);
     return displayName;
 }