[vlc-commits] macosx: fixed a 300 byte memory leak

Felix Paul Kühne git at videolan.org
Sat Jul 23 19:33:47 CEST 2011


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sat Jul 23 19:33:26 2011 +0200| [3d432688510b010f9c886f973d6fea84d8401039] | committer: Felix Paul Kühne

macosx: fixed a 300 byte memory leak

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3d432688510b010f9c886f973d6fea84d8401039
---

 modules/gui/macosx/MainMenu.m     |   80 +++++++++++++++++++++++++++++-------
 modules/gui/macosx/VideoEffects.m |    3 +
 2 files changed, 67 insertions(+), 16 deletions(-)

diff --git a/modules/gui/macosx/MainMenu.m b/modules/gui/macosx/MainMenu.m
index 77b1662..692b707 100644
--- a/modules/gui/macosx/MainMenu.m
+++ b/modules/gui/macosx/MainMenu.m
@@ -101,6 +101,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
     playlist_t *p_playlist;
     vlc_value_t val;
     id o_vlcmain = [VLCMain sharedInstance];
+    char * key;
 
     /* Check if we already did this once. Opening the other nibs calls it too,
      because VLCMain is the owner */
@@ -108,54 +109,101 @@ static VLCMainMenu *_o_sharedInstance = nil;
 
     [self initStrings];
 
-    o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-quit" )];
+    key = config_GetPsz( p_intf, "key-quit" );
+    o_key = [NSString stringWithFormat:@"%s", key];
     [o_mi_quit setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
     [o_mi_quit setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
-    o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-play-pause" )];
+    FREENULL( key );
+
+    key = config_GetPsz( p_intf, "key-play-pause" );
+    o_key = [NSString stringWithFormat:@"%s", key];
     [o_mi_play setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
     [o_mi_play setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
-    o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-stop" )];
+    FREENULL( key );
+
+    key = config_GetPsz( p_intf, "key-stop" );
+    o_key = [NSString stringWithFormat:@"%s", key];
     [o_mi_stop setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
     [o_mi_stop setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
-    o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-prev" )];
+    FREENULL( key );
+
+    key = config_GetPsz( p_intf, "key-prev" );
+    o_key = [NSString stringWithFormat:@"%s", key];
     [o_mi_previous setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
     [o_mi_previous setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
-    o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-next" )];
+    FREENULL( key );
+
+    key = config_GetPsz( p_intf, "key-next" );
+    o_key = [NSString stringWithFormat:@"%s", key];
     [o_mi_next setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
     [o_mi_next setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
-    o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-jump+short" )];
+    FREENULL( key );
+
+    key = config_GetPsz( p_intf, "key-jump+short" );
+    o_key = [NSString stringWithFormat:@"%s", key];
     [o_mi_fwd setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
     [o_mi_fwd setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
-    o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-jump-short" )];
+    FREENULL( key );
+
+    key = config_GetPsz( p_intf, "key-jump-short" );
+    o_key = [NSString stringWithFormat:@"%s", key];
     [o_mi_bwd setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
     [o_mi_bwd setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
-    o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-vol-up" )];
+    FREENULL( key );
+
+    key = config_GetPsz( p_intf, "key-vol-up" );
+    o_key = [NSString stringWithFormat:@"%s", key];
     [o_mi_vol_up setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
     [o_mi_vol_up setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
-    o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-vol-down" )];
+    FREENULL( key );
+
+    key = config_GetPsz( p_intf, "key-vol-down" );
+    o_key = [NSString stringWithFormat:@"%s", key];
     [o_mi_vol_down setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
     [o_mi_vol_down setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
-    o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-vol-mute" )];
+    FREENULL( key );
+
+    key = config_GetPsz( p_intf, "key-vol-mute" );
+    o_key = [NSString stringWithFormat:@"%s", key];
     [o_mi_mute setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
     [o_mi_mute setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
-    o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-toggle-fullscreen" )];
+    FREENULL( key );
+
+    key = config_GetPsz( p_intf, "key-toggle-fullscreen" );
+    o_key = [NSString stringWithFormat:@"%s", key];
     [o_mi_fullscreen setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
     [o_mi_fullscreen setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
-    o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-snapshot" )];
+    FREENULL( key );
+
+    key = config_GetPsz( p_intf, "key-snapshot" );
+    o_key = [NSString stringWithFormat:@"%s", key];
     [o_mi_snapshot setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
     [o_mi_snapshot setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
-    o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-random" )];
+    FREENULL( key );
+
+    key = config_GetPsz( p_intf, "key-random" );
+    o_key = [NSString stringWithFormat:@"%s", key];
     [o_mi_random setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
     [o_mi_random setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
-    o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-zoom-half" )];
+    FREENULL( key );
+
+    key = config_GetPsz( p_intf, "key-zoom-half" );
+    o_key = [NSString stringWithFormat:@"%s", key];
     [o_mi_half_window setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
     [o_mi_half_window setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
-    o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-zoom-original" )];
+    FREENULL( key );
+
+    key = config_GetPsz( p_intf, "key-zoom-original" );
+    o_key = [NSString stringWithFormat:@"%s", key];
     [o_mi_normal_window setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
     [o_mi_normal_window setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
-    o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-zoom-double" )];
+    FREENULL( key );
+
+    key = config_GetPsz( p_intf, "key-zoom-double" );
+    o_key = [NSString stringWithFormat:@"%s", key];
     [o_mi_double_window setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
     [o_mi_double_window setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
+    FREENULL( key );
 
     [self setSubmenusEnabled: FALSE];
 
diff --git a/modules/gui/macosx/VideoEffects.m b/modules/gui/macosx/VideoEffects.m
index 2b8abaf..f24b266 100644
--- a/modules/gui/macosx/VideoEffects.m
+++ b/modules/gui/macosx/VideoEffects.m
@@ -330,6 +330,9 @@ static VLCVideoEffects *_o_sharedInstance = nil;
     [o_eraselogo_left_lbl setEnabled: [o_eraselogo_ckb state]];
     [o_eraselogo_top_fld setEnabled: [o_eraselogo_ckb state]];
     [o_eraselogo_top_lbl setEnabled: [o_eraselogo_ckb state]];
+
+    if (psz_vfilters)
+        free(psz_vfilters);
 }
 
 - (void)setVideoFilter: (char *)psz_name on:(BOOL)b_on



More information about the vlc-commits mailing list