[vlc-devel] commit: Factorization. ( Rémi Duraffort )

git version control git at videolan.org
Wed May 20 22:11:08 CEST 2009


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Wed May 20 22:06:07 2009 +0200| [7b6ed91d95282a7479c3ba60a084f67c6c058373] | committer: Rémi Duraffort 

Factorization.

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

 src/control/media_player.c |   24 ++++++++++--------------
 1 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/src/control/media_player.c b/src/control/media_player.c
index ce4cd0b..1e053e2 100644
--- a/src/control/media_player.c
+++ b/src/control/media_player.c
@@ -1167,6 +1167,8 @@ libvlc_track_description_t *
                                       libvlc_exception_t *p_e )
 {
     input_thread_t *p_input = libvlc_get_input_thread( p_mi, p_e );
+    libvlc_track_description_t *p_track_description = NULL,
+                               *p_actual, *p_previous;
 
     if( !p_input )
         return NULL;
@@ -1174,22 +1176,16 @@ libvlc_track_description_t *
     vlc_value_t val_list, text_list;
     var_Change( p_input, psz_variable, VLC_VAR_GETLIST, &val_list, &text_list);
 
-    if( val_list.p_list->i_count <= 0 ) /* no tracks */
-    {
-        var_FreeList( &val_list, &text_list);
-        vlc_object_release( p_input );
-        return NULL;
-    }
+    /* no tracks */
+    if( val_list.p_list->i_count <= 0 )
+        goto end;
 
-    libvlc_track_description_t *p_track_description, *p_actual, *p_previous;
     p_track_description = ( libvlc_track_description_t * )
         malloc( sizeof( libvlc_track_description_t ) );
     if ( !p_track_description )
     {
-        var_FreeList( &val_list, &text_list);
-        vlc_object_release( p_input );
         libvlc_exception_raise( p_e, "no enough memory" );
-        return NULL;
+        goto end;
     }
     p_actual = p_track_description;
     p_previous = NULL;
@@ -1202,10 +1198,8 @@ libvlc_track_description_t *
             if ( !p_actual )
             {
                 libvlc_track_description_release( p_track_description );
-                var_FreeList( &val_list, &text_list);
-                vlc_object_release( p_input );
                 libvlc_exception_raise( p_e, "no enough memory" );
-                return NULL;
+                goto end;
             }
         }
         p_actual->i_id = val_list.p_list->p_values[i].i_int;
@@ -1216,7 +1210,9 @@ libvlc_track_description_t *
         p_previous = p_actual;
         p_actual =  NULL;
     }
-    var_FreeList( &val_list, &text_list);
+
+end:
+    var_FreeList( &val_list, &text_list );
     vlc_object_release( p_input );
 
     return p_track_description;




More information about the vlc-devel mailing list