Commit 74b1c6cd authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Code factorization: use input_ItemAddOption

parent 25ea83eb
...@@ -498,38 +498,19 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args ) ...@@ -498,38 +498,19 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
case INPUT_ADD_OPTION: case INPUT_ADD_OPTION:
{ {
char *psz_option = (char *)va_arg( args, char * ); const char *psz_option = va_arg( args, const char * );
char *psz_value = (char *)va_arg( args, char * ); const char *psz_value = va_arg( args, const char * );
char *str;
int i; int i;
vlc_mutex_lock( &p_input->p->input.p_item->lock ); if( asprintf( &str, "%s=%s", psz_option, psz_value ) == -1 )
/* Check if option already exists */ return VLC_ENOMEM;
for( i = 0; i < p_input->p->input.p_item->i_options; i++ )
{
if( !strncmp( p_input->p->input.p_item->ppsz_options[i],
psz_option, strlen( psz_option ) ) &&
p_input->p->input.p_item->ppsz_options[i][strlen(psz_option)]
== '=' )
{
free( p_input->p->input.p_item->ppsz_options[i] );
break;
}
}
if( i == p_input->p->input.p_item->i_options )
{
p_input->p->input.p_item->i_options++;
p_input->p->input.p_item->ppsz_options =
realloc( p_input->p->input.p_item->ppsz_options,
p_input->p->input.p_item->i_options *
sizeof(char **) );
}
if( asprintf( &p_input->p->input.p_item->ppsz_options[i], input_ItemAddOpt( p_input->p->input.p_item, str,
"%s=%s", psz_option, psz_value ) == -1 ) VLC_INPUT_OPTION_UNIQUE );
p_input->p->input.p_item->ppsz_options[i] = NULL; i = VLC_SUCCESS;
vlc_mutex_unlock( &p_input->p->input.p_item->lock ); free( str );
return i;
return VLC_SUCCESS;
} }
case INPUT_GET_BYTE_POSITION: case INPUT_GET_BYTE_POSITION:
......
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