[vlc-commits] Use TAB_ERASE instead of REMOVE_ELEM

Rémi Denis-Courmont git at videolan.org
Thu May 18 20:22:33 CEST 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu May 18 21:09:20 2017 +0300| [d89c85f5ca9fd9ff1885a982a99861781cb25068] | committer: Rémi Denis-Courmont

Use TAB_ERASE instead of REMOVE_ELEM

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

 modules/lua/services_discovery.c     |  2 +-
 modules/services_discovery/podcast.c | 21 ++++++++++-----------
 modules/stream_out/rtp.c             |  2 +-
 modules/stream_out/rtsp.c            |  6 +++---
 src/input/info.h                     |  2 +-
 src/input/item.c                     |  2 +-
 src/input/stats.c                    |  2 +-
 src/misc/variables.c                 |  8 ++++----
 src/playlist/item.c                  |  4 ++--
 src/playlist/services_discovery.c    |  2 +-
 10 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/modules/lua/services_discovery.c b/modules/lua/services_discovery.c
index 84d525280a..f5581c7f9a 100644
--- a/modules/lua/services_discovery.c
+++ b/modules/lua/services_discovery.c
@@ -315,7 +315,7 @@ static void* Run( void *data )
 
         /* Execute one query (protected against cancellation) */
         char *psz_query = p_sys->ppsz_query[p_sys->i_query - 1];
-        REMOVE_ELEM( p_sys->ppsz_query, p_sys->i_query, p_sys->i_query - 1 );
+        TAB_ERASE(p_sys->i_query, p_sys->ppsz_query, p_sys->i_query - 1);
         vlc_mutex_unlock( &p_sys->lock );
 
         cancel = vlc_savecancel();
diff --git a/modules/services_discovery/podcast.c b/modules/services_discovery/podcast.c
index 03595e94cb..d5b3908233 100644
--- a/modules/services_discovery/podcast.c
+++ b/modules/services_discovery/podcast.c
@@ -248,7 +248,7 @@ noreturn static void *Run( void *data )
                 input_Close( p_input );
 
                 p_sd->p_sys->pp_input[i] = NULL;
-                REMOVE_ELEM( p_sys->pp_input, p_sys->i_input, i );
+                TAB_ERASE(p_sys->i_input, p_sys->pp_input, i);
                 i--;
             }
         }
@@ -411,16 +411,15 @@ static void ParseRequest( services_discovery_t *p_sd )
     else if ( !strcmp( psz_request, "RM" ) )
     {
         psz_request = psz_tok + 1;
-        for( i = 0; i<p_sys->i_urls; i++ )
-          if( !strcmp(p_sys->ppsz_urls[i],psz_request) )
-            break;
-        if( i != p_sys->i_urls )
-        {
-            services_discovery_RemoveItem( p_sd, p_sys->pp_items[i] );
-            input_item_Release( p_sys->pp_items[i] );
-            REMOVE_ELEM( p_sys->ppsz_urls, p_sys->i_urls, i );
-            REMOVE_ELEM( p_sys->pp_items, p_sys->i_items, i );
-        }
+        for( i = 0; i < p_sys->i_urls; i++ )
+            if( !strcmp(p_sys->ppsz_urls[i], psz_request) )
+            {
+                services_discovery_RemoveItem( p_sd, p_sys->pp_items[i] );
+                input_item_Release( p_sys->pp_items[i] );
+                TAB_ERASE(p_sys->i_urls, p_sys->ppsz_urls, i );
+                TAB_ERASE(p_sys->i_items, p_sys->pp_items, i );
+                break;
+            }
         SaveUrls( p_sd );
     }
 
diff --git a/modules/stream_out/rtp.c b/modules/stream_out/rtp.c
index 5b659793f1..2475aa1469 100644
--- a/modules/stream_out/rtp.c
+++ b/modules/stream_out/rtp.c
@@ -1529,7 +1529,7 @@ void rtp_del_sink( sout_stream_id_sys_t *id, int fd )
         if (id->sinkv[i].rtp_fd == fd)
         {
             sink = id->sinkv[i];
-            REMOVE_ELEM( id->sinkv, id->sinkc, i );
+            TAB_ERASE(id->sinkc, id->sinkv, i);
             break;
         }
     }
diff --git a/modules/stream_out/rtsp.c b/modules/stream_out/rtsp.c
index b5bce43393..35ee7e7776 100644
--- a/modules/stream_out/rtsp.c
+++ b/modules/stream_out/rtsp.c
@@ -287,7 +287,7 @@ void RtspDelId( rtsp_stream_t *rtsp, rtsp_stream_id_t *id )
             {
                 rtsp_strack_t *tr = ses->trackv + j;
                 RtspTrackClose( tr );
-                REMOVE_ELEM( ses->trackv, ses->trackc, j );
+                TAB_ERASE(ses->trackc, ses->trackv, j);
             }
         }
     }
@@ -509,7 +509,7 @@ void RtspTrackDetach( rtsp_stream_t *rtsp, const char *name,
                 /* No (more) SETUP information: better get rid of the
                  * track so that we can have new random ssrc and
                  * seq_init next time. */
-                REMOVE_ELEM( session->trackv, session->trackc, i );
+                TAB_ERASE(session->trackc, session->trackv, i);
                 break;
             }
             /* We keep the SETUP information of the track, but stop it */
@@ -1161,7 +1161,7 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
                             /* Keep VoD tracks whose instance is still
                              * running */
                             if (!(vod && ses->trackv[i].sout_id != NULL))
-                                REMOVE_ELEM( ses->trackv, ses->trackc, i );
+                                TAB_ERASE(ses->trackc, ses->trackv, i);
                         }
                     }
                     RtspClientAlive(ses);
diff --git a/src/input/info.h b/src/input/info.h
index 5785cfca44..2752c5bad4 100644
--- a/src/input/info.h
+++ b/src/input/info.h
@@ -116,7 +116,7 @@ static inline int info_category_DeleteInfo(info_category_t *cat, const char *nam
     int index;
     if (info_category_FindInfo(cat, &index, name)) {
         info_Delete(cat->pp_infos[index]);
-        REMOVE_ELEM(cat->pp_infos, cat->i_infos, index);
+        TAB_ERASE(cat->i_infos, cat->pp_infos, index);
         return VLC_SUCCESS;
     }
     return VLC_EGENERIC;
diff --git a/src/input/item.c b/src/input/item.c
index 3dd21bbbd8..41a2b98b77 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -810,7 +810,7 @@ int input_item_DelInfo( input_item_t *p_i,
     {
         /* Remove the complete categorie */
         info_category_Delete( p_cat );
-        REMOVE_ELEM( p_i->pp_categories, p_i->i_categories, i_cat );
+        TAB_ERASE(p_i->i_categories, p_i->pp_categories, i_cat);
     }
     vlc_mutex_unlock( &p_i->lock );
 
diff --git a/src/input/stats.c b/src/input/stats.c
index ee61546fb2..d7ee85a6e1 100644
--- a/src/input/stats.c
+++ b/src/input/stats.c
@@ -181,7 +181,7 @@ void stats_Update( counter_t *p_counter, uint64_t val, uint64_t *new_val )
         if( p_counter->i_samples == 3 )
         {
             p_old = p_counter->pp_samples[2];
-            REMOVE_ELEM( p_counter->pp_samples, p_counter->i_samples, 2 );
+            TAB_ERASE(p_counter->i_samples, p_counter->pp_samples, 2);
             free( p_old );
         }
         break;
diff --git a/src/misc/variables.c b/src/misc/variables.c
index bcc9f3dcd0..5e9ba678a8 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -533,9 +533,9 @@ int var_Change( vlc_object_t *p_this, const char *psz_name,
 
             p_var->ops->pf_free( &p_var->choices.p_values[i] );
             free( p_var->choices_text.p_values[i].psz_string );
-            REMOVE_ELEM( p_var->choices.p_values, p_var->choices.i_count, i );
-            REMOVE_ELEM( p_var->choices_text.p_values,
-                         p_var->choices_text.i_count, i );
+            TAB_ERASE(p_var->choices.i_count, p_var->choices.p_values, i);
+            TAB_ERASE(p_var->choices_text.i_count,
+                      p_var->choices_text.p_values, i);
 
             TriggerListCallback(p_this, p_var, psz_name, VLC_VAR_DELCHOICE, p_val);
             break;
@@ -938,7 +938,7 @@ static void DelCallback( vlc_object_t *p_this, const char *psz_name,
         return;
     }
 
-    REMOVE_ELEM( p_table->p_entries, p_table->i_entries, i_entry );
+    TAB_ERASE(p_table->i_entries, p_table->p_entries, i_entry);
 
     vlc_mutex_unlock( &p_priv->var_lock );
 }
diff --git a/src/playlist/item.c b/src/playlist/item.c
index 130a4d9383..e912b0bcbc 100644
--- a/src/playlist/item.c
+++ b/src/playlist/item.c
@@ -611,7 +611,7 @@ int playlist_TreeMove( playlist_t * p_playlist, playlist_item_t *p_item,
     playlist_item_t *p_detach = p_item->p_parent;
     int i_index = ItemIndex( p_item );
 
-    REMOVE_ELEM( p_detach->pp_children, p_detach->i_children, i_index );
+    TAB_ERASE(p_detach->i_children, p_detach->pp_children, i_index);
 
     if( p_detach == p_node && i_index < i_newpos )
         i_newpos--;
@@ -649,7 +649,7 @@ int playlist_TreeMoveMany( playlist_t *p_playlist,
         playlist_item_t *p_item = pp_items[i];
         int i_index = ItemIndex( p_item );
         playlist_item_t *p_parent = p_item->p_parent;
-        REMOVE_ELEM( p_parent->pp_children, p_parent->i_children, i_index );
+        TAB_ERASE(p_parent->i_children, p_parent->pp_children, i_index);
         if ( p_parent == p_node && i_index < i_newpos ) i_newpos--;
     }
     for( int i = i_items - 1; i >= 0; i-- )
diff --git a/src/playlist/services_discovery.c b/src/playlist/services_discovery.c
index 55573fdc73..1392afb29f 100644
--- a/src/playlist/services_discovery.c
+++ b/src/playlist/services_discovery.c
@@ -172,7 +172,7 @@ int playlist_ServicesDiscoveryRemove(playlist_t *playlist, const char *name)
 
         if (!strcmp(name, entry->name))
         {
-            REMOVE_ELEM(priv->pp_sds, priv->i_sds, i);
+            TAB_ERASE(priv->i_sds, priv->pp_sds, i);
             sds = entry;
             break;
         }



More information about the vlc-commits mailing list