[vlc-commits] input: remove antilogy, add error handling and simplify

Rémi Denis-Courmont git at videolan.org
Wed Jun 17 23:11:13 CEST 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jun 18 00:02:57 2015 +0300| [6e6873d3e2b1163be50f7984b8d348f9a34fd76c] | committer: Rémi Denis-Courmont

input: remove antilogy, add error handling and simplify

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

 src/input/control.c |   26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/src/input/control.c b/src/input/control.c
index 6d45d7f..e498566 100644
--- a/src/input/control.c
+++ b/src/input/control.c
@@ -360,34 +360,26 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
 
         case INPUT_GET_FULL_TITLE_INFO:
         {
-            input_title_t ***array = (input_title_t ***)va_arg( args, input_title_t *** );
-            int *count = (int *) va_arg( args, int * );
+            input_title_t **array;
+            unsigned count;
 
             vlc_mutex_lock( &p_input->p->p_item->lock );
+            count = p_input->p->i_title;
+            array = malloc( count * sizeof (*array) );
 
-            const int i_titles = p_input->p->i_title;
-            *count = i_titles;
-
-            if( i_titles == 0 )
-            {
-                vlc_mutex_unlock( &p_input->p->p_item->lock );
-                return VLC_EGENERIC;
-            }
-
-            *array = calloc( i_titles, sizeof(**array) );
-            if (!array )
+            if( count > 0 && unlikely(array == NULL) )
             {
                 vlc_mutex_unlock( &p_input->p->p_item->lock );
                 return VLC_ENOMEM;
             }
 
-            for( int i = 0; i < i_titles; i++ )
-            {
-                (*array)[i] = vlc_input_title_Duplicate( p_input->p->title[i] );
-            }
+            for( unsigned i = 0; i < count; i++ )
+                array[i] = vlc_input_title_Duplicate( p_input->p->title[i] );
 
             vlc_mutex_unlock( &p_input->p->p_item->lock );
 
+            *va_arg( args, input_title_t *** ) = array;
+            *va_arg( args, int * ) = count;
             return VLC_SUCCESS;
         }
 



More information about the vlc-commits mailing list