[vlc-commits] Use TAB_APPEND instead of INSERT_ELEM where applicable
Rémi Denis-Courmont
git at videolan.org
Thu May 18 20:22:01 CEST 2017
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu May 18 20:47:15 2017 +0300| [c223268f6e2a6f42ec15a1056a025f67c0afae59] | committer: Rémi Denis-Courmont
Use TAB_APPEND instead of INSERT_ELEM where applicable
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c223268f6e2a6f42ec15a1056a025f67c0afae59
---
modules/demux/playlist/m3u.c | 3 +--
modules/demux/playlist/ram.c | 6 +++---
modules/gui/ncurses.c | 6 ++----
modules/lua/vlc.c | 3 +--
modules/services_discovery/podcast.c | 21 ++++++++++-----------
modules/services_discovery/sap.c | 3 +--
modules/stream_out/rtp.c | 2 +-
modules/stream_out/rtsp.c | 5 ++---
src/input/access.c | 3 +--
src/input/info.h | 7 +++----
src/input/input.c | 8 ++++----
src/input/item.c | 23 ++++++-----------------
src/input/stats.c | 3 +--
src/input/subtitles.c | 2 +-
src/misc/variables.c | 14 ++++++--------
15 files changed, 43 insertions(+), 66 deletions(-)
diff --git a/modules/demux/playlist/m3u.c b/modules/demux/playlist/m3u.c
index 8137ac3284..651be26440 100644
--- a/modules/demux/playlist/m3u.c
+++ b/modules/demux/playlist/m3u.c
@@ -228,8 +228,7 @@ static int Demux( demux_t *p_demux )
psz_option = pf_dup( psz_parse );
if( psz_option )
- INSERT_ELEM( ppsz_options, i_options, i_options,
- psz_option );
+ TAB_APPEND( i_options, ppsz_options, psz_option );
}
/* Special case for jamendo which provide the albumart */
else if( !strncasecmp( psz_parse, "EXTALBUMARTURL:",
diff --git a/modules/demux/playlist/ram.c b/modules/demux/playlist/ram.c
index f9aca44e23..708a2aac8a 100644
--- a/modules/demux/playlist/ram.c
+++ b/modules/demux/playlist/ram.c
@@ -294,7 +294,7 @@ static int Demux( demux_t *p_demux )
if( i_start )
{
if( asprintf( &temp, ":start-time=%d", i_start ) != -1 )
- INSERT_ELEM( ppsz_options, i_options, i_options, temp );
+ TAB_APPEND( i_options, ppsz_options, temp );
}
}
else if( !strcmp( psz_param, "end" ) )
@@ -304,7 +304,7 @@ static int Demux( demux_t *p_demux )
if( i_stop )
{
if( asprintf( &temp, ":stop-time=%d", i_stop ) != -1 )
- INSERT_ELEM( ppsz_options, i_options, i_options, temp );
+ TAB_APPEND( i_options, ppsz_options, temp );
}
}
else if( !strcmp( psz_param, "title" ) )
@@ -320,7 +320,7 @@ static int Demux( demux_t *p_demux )
}
else
{ /* TODO: insert option anyway? Currently ignores*/
- /* INSERT_ELEM( ppsz_options, i_options, i_options, psz_option ); */
+ //TAB_APPEND( i_options, ppsz_options, psz_option );
}
}
}
diff --git a/modules/gui/ncurses.c b/modules/gui/ncurses.c
index 179072549d..4075313462 100644
--- a/modules/gui/ncurses.c
+++ b/modules/gui/ncurses.c
@@ -295,8 +295,7 @@ static void ReadDir(intf_thread_t *intf)
dir_entry->file = IsFile(sys->current_dir, entry);
dir_entry->path = xstrdup(entry);
- INSERT_ELEM(sys->dir_entries, sys->n_dir_entries,
- sys->n_dir_entries, dir_entry);
+ TAB_APPEND(sys->n_dir_entries, sys->dir_entries, dir_entry);
continue;
}
@@ -375,8 +374,7 @@ static bool PlaylistAddChild(intf_sys_t *sys, playlist_item_t *p_child,
free(name);
p_pl_item->item = input_item_Hold(p_child->p_input);
- INSERT_ELEM(sys->plist, sys->plist_entries,
- sys->plist_entries, p_pl_item);
+ TAB_APPEND(sys->plist_entries, sys->plist, p_pl_item);
return true;
diff --git a/modules/lua/vlc.c b/modules/lua/vlc.c
index 86d7332c1e..512d9e505c 100644
--- a/modules/lua/vlc.c
+++ b/modules/lua/vlc.c
@@ -432,8 +432,7 @@ void vlclua_read_options( vlc_object_t *p_this, lua_State *L,
{
char *psz_option = strdup( lua_tostring( L, -1 ) );
msg_Dbg( p_this, "Option: %s", psz_option );
- INSERT_ELEM( *pppsz_options, *pi_options, *pi_options,
- psz_option );
+ TAB_APPEND( *pi_options, *pppsz_options, psz_option );
}
else
{
diff --git a/modules/services_discovery/podcast.c b/modules/services_discovery/podcast.c
index ba61c802bd..03595e94cb 100644
--- a/modules/services_discovery/podcast.c
+++ b/modules/services_discovery/podcast.c
@@ -319,24 +319,23 @@ static void ParseUrls( services_discovery_t *p_sd, char *psz_urls )
break;
if( i == p_sys->i_urls )
{
- INSERT_ELEM( ppsz_new_urls, i_new_urls, i_new_urls,
- strdup( psz_urls ) );
+ TAB_APPEND( i_new_urls, ppsz_new_urls, strdup( psz_urls ) );
input_item_t *p_input;
p_input = input_item_New( psz_urls, psz_urls );
input_item_AddOption( p_input, "demux=podcast", VLC_INPUT_OPTION_TRUSTED );
- INSERT_ELEM( pp_new_items, i_new_items, i_new_items, p_input );
+ TAB_APPEND( i_new_items, pp_new_items, p_input );
services_discovery_AddItem( p_sd, p_input );
- INSERT_ELEM( p_sys->pp_input, p_sys->i_input, p_sys->i_input,
+ TAB_APPEND( p_sys->i_input, p_sys->pp_input,
input_CreateAndStart( p_sd, p_input, NULL ) );
}
else
{
- INSERT_ELEM( ppsz_new_urls, i_new_urls, i_new_urls,
+ TAB_APPEND( i_new_urls, ppsz_new_urls,
strdup( p_sys->ppsz_urls[i]) );
- INSERT_ELEM( pp_new_items, i_new_items, i_new_items, p_sys->pp_items[i] );
+ TAB_APPEND( i_new_items, pp_new_items, p_sys->pp_items[i] );
}
if( psz_tok )
psz_urls = psz_tok+1;
@@ -394,18 +393,18 @@ static void ParseRequest( services_discovery_t *p_sd )
break;
if( i == p_sys->i_urls )
{
- INSERT_ELEM( p_sys->ppsz_urls, p_sys->i_urls, p_sys->i_urls,
- strdup( psz_request ) );
+ TAB_APPEND( p_sys->i_urls, p_sys->ppsz_urls,
+ strdup( psz_request ) );
input_item_t *p_input;
p_input = input_item_New( psz_request, psz_request );
input_item_AddOption( p_input, "demux=podcast", VLC_INPUT_OPTION_TRUSTED );
- INSERT_ELEM( p_sys->pp_items, p_sys->i_items, p_sys->i_items, p_input );
+ TAB_APPEND( p_sys->i_items, p_sys->pp_items, p_input );
services_discovery_AddItem( p_sd, p_input );
- INSERT_ELEM( p_sys->pp_input, p_sys->i_input, p_sys->i_input,
- input_CreateAndStart( p_sd, p_input, NULL ) );
+ TAB_APPEND( p_sys->i_input, p_sys->pp_input,
+ input_CreateAndStart( p_sd, p_input, NULL ) );
SaveUrls( p_sd );
}
}
diff --git a/modules/services_discovery/sap.c b/modules/services_discovery/sap.c
index 48729c671f..a8361efb2f 100644
--- a/modules/services_discovery/sap.c
+++ b/modules/services_discovery/sap.c
@@ -1471,8 +1471,7 @@ static int InitSocket( services_discovery_t *p_sd, const char *psz_address,
return VLC_EGENERIC;
shutdown( i_fd, SHUT_WR );
- INSERT_ELEM (p_sd->p_sys->pi_fd, p_sd->p_sys->i_fd,
- p_sd->p_sys->i_fd, i_fd);
+ TAB_APPEND(p_sd->p_sys->i_fd, p_sd->p_sys->pi_fd, i_fd);
return VLC_SUCCESS;
}
diff --git a/modules/stream_out/rtp.c b/modules/stream_out/rtp.c
index 671ba73965..5b659793f1 100644
--- a/modules/stream_out/rtp.c
+++ b/modules/stream_out/rtp.c
@@ -1511,7 +1511,7 @@ int rtp_add_sink( sout_stream_id_sys_t *id, int fd, bool rtcp_mux, uint16_t *seq
msg_Err( id->p_stream, "RTCP failed!" );
vlc_mutex_lock( &id->lock_sink );
- INSERT_ELEM( id->sinkv, id->sinkc, id->sinkc, sink );
+ TAB_APPEND(id->sinkc, id->sinkv, sink);
if( seq != NULL )
*seq = id->i_seq_sent_next;
vlc_mutex_unlock( &id->lock_sink );
diff --git a/modules/stream_out/rtsp.c b/modules/stream_out/rtsp.c
index dc354d1f96..b5bce43393 100644
--- a/modules/stream_out/rtsp.c
+++ b/modules/stream_out/rtsp.c
@@ -463,7 +463,7 @@ int RtspTrackAttach( rtsp_stream_t *rtsp, const char *name,
vlc_rand_bytes (&track.seq_init, sizeof (track.seq_init));
vlc_rand_bytes (&track.ssrc, sizeof (track.ssrc));
- INSERT_ELEM(session->trackv, session->trackc, session->trackc, track);
+ TAB_APPEND(session->trackc, session->trackv, track);
tr = session->trackv + session->trackc - 1;
}
@@ -879,8 +879,7 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
else
ssrc = id->ssrc;
- INSERT_ELEM( ses->trackv, ses->trackc, ses->trackc,
- track );
+ TAB_APPEND(ses->trackc, ses->trackv, track);
}
else if (tr->setup_fd == -1)
{
diff --git a/src/input/access.c b/src/input/access.c
index 2b1a9cc592..8986a25edf 100644
--- a/src/input/access.c
+++ b/src/input/access.c
@@ -687,8 +687,7 @@ int access_fsdir_additem(struct access_fsdir *p_fsdir,
return VLC_ENOMEM;
}
- INSERT_ELEM(p_fsdir->pp_slaves, p_fsdir->i_slaves,
- p_fsdir->i_slaves, p_fsdir_slave);
+ TAB_APPEND(p_fsdir->i_slaves, p_fsdir->pp_slaves, p_fsdir_slave);
}
if (fsdir_is_ignored(p_fsdir, psz_filename))
diff --git a/src/input/info.h b/src/input/info.h
index 9dcc4ca8f9..5785cfca44 100644
--- a/src/input/info.h
+++ b/src/input/info.h
@@ -77,9 +77,8 @@ static inline void info_category_ReplaceInfo(info_category_t *cat,
if (old) {
info_Delete(cat->pp_infos[index]);
cat->pp_infos[index] = info;
- } else {
- INSERT_ELEM(cat->pp_infos, cat->i_infos, cat->i_infos, info);
- }
+ } else
+ TAB_APPEND(cat->i_infos, cat->pp_infos, info);
}
static inline info_t *info_category_VaAddInfo(info_category_t *cat,
@@ -91,7 +90,7 @@ static inline info_t *info_category_VaAddInfo(info_category_t *cat,
info = info_New(name, NULL);
if (!info)
return NULL;
- INSERT_ELEM(cat->pp_infos, cat->i_infos, cat->i_infos, info);
+ TAB_APPEND(cat->i_infos, cat->pp_infos, info);
} else
free(info->psz_value);
if (vasprintf(&info->psz_value, format, args) == -1)
diff --git a/src/input/input.c b/src/input/input.c
index ddc638e529..63b3c47f5e 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -1032,7 +1032,7 @@ static void GetVarSlaves( input_thread_t *p_input,
if( unlikely( p_slave == NULL ) )
break;
- INSERT_ELEM( pp_slaves, i_slaves, i_slaves, p_slave );
+ TAB_APPEND(i_slaves, pp_slaves, p_slave);
}
free( psz_org );
@@ -1063,7 +1063,7 @@ static void LoadSlaves( input_thread_t *p_input )
free( psz_uri );
if( p_slave )
{
- INSERT_ELEM( pp_slaves, i_slaves, i_slaves, p_slave );
+ TAB_APPEND(i_slaves, pp_slaves, p_slave);
psz_subtitle = p_slave->psz_uri;
}
}
@@ -1105,7 +1105,7 @@ static void LoadSlaves( input_thread_t *p_input )
{
input_item_slave_t *p_slave = p_item->pp_slaves[i];
if( !SlaveExists( pp_slaves, i_slaves, p_slave->psz_uri ) )
- INSERT_ELEM( pp_slaves, i_slaves, i_slaves, p_slave );
+ TAB_APPEND(i_slaves, pp_slaves, p_slave);
else
input_item_slave_Delete( p_slave );
}
@@ -1238,7 +1238,7 @@ static void InitPrograms( input_thread_t * p_input )
prgm = strtok_r( NULL, ",", &buf ) )
{
vlc_value_t val = { .i_int = atoi( prgm ) };
- INSERT_ELEM( list.p_values, list.i_count, list.i_count, val );
+ TAB_APPEND(list.i_count, list.p_values, val);
}
if( list.i_count > 0 )
diff --git a/src/input/item.c b/src/input/item.c
index 756c5e7ec8..92b473b79d 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -569,8 +569,7 @@ int input_item_AddOption( input_item_t *p_input, const char *psz_option,
goto out;
}
- INSERT_ELEM( p_input->ppsz_options, p_input->i_options,
- p_input->i_options, psz_option_dup );
+ TAB_APPEND(p_input->i_options, p_input->ppsz_options, psz_option_dup);
flagv[p_input->optflagc++] = flags;
@@ -685,7 +684,7 @@ int input_item_AddSlave(input_item_t *p_item, input_item_slave_t *p_slave)
vlc_mutex_lock( &p_item->lock );
- INSERT_ELEM( p_item->pp_slaves, p_item->i_slaves, p_item->i_slaves, p_slave );
+ TAB_APPEND(p_item->i_slaves, p_item->pp_slaves, p_slave);
vlc_mutex_unlock( &p_item->lock );
return VLC_SUCCESS;
@@ -753,8 +752,7 @@ static int InputItemVaAddInfo( input_item_t *p_i,
p_cat = info_category_New( psz_cat );
if( !p_cat )
return VLC_ENOMEM;
- INSERT_ELEM( p_i->pp_categories, p_i->i_categories, p_i->i_categories,
- p_cat );
+ TAB_APPEND(p_i->i_categories, p_i->pp_categories, p_cat);
}
info_t *p_info = info_category_VaAddInfo( p_cat, psz_name, psz_format, args );
if( !p_info || !p_info->psz_value )
@@ -832,10 +830,7 @@ void input_item_ReplaceInfos( input_item_t *p_item, info_category_t *p_cat )
p_item->pp_categories[i_cat] = p_cat;
}
else
- {
- INSERT_ELEM( p_item->pp_categories, p_item->i_categories, p_item->i_categories,
- p_cat );
- }
+ TAB_APPEND(p_item->i_categories, p_item->pp_categories, p_cat);
vlc_mutex_unlock( &p_item->lock );
vlc_event_send( &p_item->event_manager,
@@ -854,10 +849,7 @@ void input_item_MergeInfos( input_item_t *p_item, info_category_t *p_cat )
info_category_Delete( p_cat );
}
else
- {
- INSERT_ELEM( p_item->pp_categories, p_item->i_categories, p_item->i_categories,
- p_cat );
- }
+ TAB_APPEND(p_item->i_categories, p_item->pp_categories, p_cat);
vlc_mutex_unlock( &p_item->lock );
vlc_event_send( &p_item->event_manager,
@@ -1304,10 +1296,7 @@ input_item_node_t *input_item_node_AppendItem( input_item_node_t *p_node, input_
void input_item_node_AppendNode( input_item_node_t *p_parent, input_item_node_t *p_child )
{
assert( p_parent && p_child && p_child->p_parent == NULL );
- INSERT_ELEM( p_parent->pp_children,
- p_parent->i_children,
- p_parent->i_children,
- p_child );
+ TAB_APPEND(p_parent->i_children, p_parent->pp_children, p_child);
p_child->p_parent = p_parent;
}
diff --git a/src/input/stats.c b/src/input/stats.c
index 7ee12850a0..e406a657cb 100644
--- a/src/input/stats.c
+++ b/src/input/stats.c
@@ -202,8 +202,7 @@ void stats_Update( counter_t *p_counter, uint64_t val, uint64_t *new_val )
p_new->value = 0;
- INSERT_ELEM( p_counter->pp_samples, p_counter->i_samples,
- p_counter->i_samples, p_new );
+ TAB_APPEND(p_counter->i_samples, p_counter->pp_samples, p_new);
}
if( p_counter->i_samples == 1 )
{
diff --git a/src/input/subtitles.c b/src/input/subtitles.c
index 60358f650b..d3989337df 100644
--- a/src/input/subtitles.c
+++ b/src/input/subtitles.c
@@ -352,7 +352,7 @@ int subtitles_Detect( input_thread_t *p_this, char *psz_path, const char *psz_na
if( p_sub )
{
p_sub->b_forced = true;
- INSERT_ELEM( pp_slaves, i_slaves, i_slaves, p_sub );
+ TAB_APPEND(i_slaves, pp_slaves, p_sub);
}
free( psz_uri );
}
diff --git a/src/misc/variables.c b/src/misc/variables.c
index 72296111e1..bcc9f3dcd0 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -503,10 +503,11 @@ int var_Change( vlc_object_t *p_this, const char *psz_name,
{
int i = p_var->choices.i_count;
- INSERT_ELEM( p_var->choices.p_values, p_var->choices.i_count,
- i, *p_val );
- INSERT_ELEM( p_var->choices_text.p_values,
- p_var->choices_text.i_count, i, *p_val );
+ TAB_APPEND(p_var->choices.i_count,
+ p_var->choices.p_values, *p_val);
+ assert(i == p_var->choices_text.i_count);
+ TAB_APPEND(p_var->choices_text.i_count,
+ p_var->choices_text.p_values, *p_val);
p_var->ops->pf_dup( &p_var->choices.p_values[i] );
p_var->choices_text.p_values[i].psz_string =
( p_val2 && p_val2->psz_string ) ?
@@ -850,10 +851,7 @@ static void AddCallback( vlc_object_t *p_this, const char *psz_name,
p_table = &p_var->value_callbacks;
else
p_table = &p_var->list_callbacks;
- INSERT_ELEM( p_table->p_entries,
- p_table->i_entries,
- p_table->i_entries,
- entry);
+ TAB_APPEND(p_table->i_entries, p_table->p_entries, entry);
vlc_mutex_unlock( &p_priv->var_lock );
}
More information about the vlc-commits
mailing list