Commit 6e6873d3 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

input: remove antilogy, add error handling and simplify

parent 63506d5a
...@@ -360,34 +360,26 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args ) ...@@ -360,34 +360,26 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
case INPUT_GET_FULL_TITLE_INFO: case INPUT_GET_FULL_TITLE_INFO:
{ {
input_title_t ***array = (input_title_t ***)va_arg( args, input_title_t *** ); input_title_t **array;
int *count = (int *) va_arg( args, int * ); unsigned count;
vlc_mutex_lock( &p_input->p->p_item->lock ); 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; if( count > 0 && unlikely(array == NULL) )
*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 )
{ {
vlc_mutex_unlock( &p_input->p->p_item->lock ); vlc_mutex_unlock( &p_input->p->p_item->lock );
return VLC_ENOMEM; return VLC_ENOMEM;
} }
for( int i = 0; i < i_titles; i++ ) for( unsigned i = 0; i < count; i++ )
{ array[i] = vlc_input_title_Duplicate( p_input->p->title[i] );
(*array)[i] = vlc_input_title_Duplicate( p_input->p->title[i] );
}
vlc_mutex_unlock( &p_input->p->p_item->lock ); vlc_mutex_unlock( &p_input->p->p_item->lock );
*va_arg( args, input_title_t *** ) = array;
*va_arg( args, int * ) = count;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment