[vlc-devel] [RFC 1/3] vlc_arrays: rename item_at_index() to get()

Romain Vimont rom1v at videolabs.io
Thu Jul 19 17:57:16 CEST 2018


---
 include/vlc_arrays.h                         |  8 ++++----
 include/vlc_fingerprinter.h                  |  2 +-
 lib/event.c                                  |  6 +++---
 lib/media_list.c                             |  6 +++---
 modules/access/bluray.c                      | 10 +++++-----
 modules/access/dsm/sd.c                      |  4 ++--
 modules/access_output/livehttp.c             | 14 +++++++-------
 modules/codec/webvtt/subsvtt.c               |  6 +++---
 modules/control/dbus/dbus.c                  | 14 +++++++-------
 modules/gui/qt/dialogs/fingerprintdialog.cpp |  2 +-
 modules/misc/fingerprinter.c                 | 14 +++++++-------
 modules/mux/asf.c                            | 14 +++++++-------
 modules/services_discovery/microdns.c        |  6 +++---
 src/input/mrl_helpers.h                      |  2 +-
 src/input/stream_extractor.c                 |  4 ++--
 src/interface/dialog.c                       |  2 +-
 src/misc/background_worker.c                 |  4 ++--
 src/misc/httpcookies.c                       |  6 +++---
 src/stream_output/stream_output.c            | 10 +++++-----
 src/test/mrl_helpers.c                       |  2 +-
 src/video_output/video_output.c              |  2 +-
 21 files changed, 69 insertions(+), 69 deletions(-)

diff --git a/include/vlc_arrays.h b/include/vlc_arrays.h
index bc2ae2ae6d7..00f816638f4 100644
--- a/include/vlc_arrays.h
+++ b/include/vlc_arrays.h
@@ -280,18 +280,18 @@ static inline size_t vlc_array_count( vlc_array_t * p_array )
 }
 
 #ifndef __cplusplus
-# define vlc_array_item_at_index(ar, idx) \
+# define vlc_array_get(ar, idx) \
     _Generic((ar), \
         const vlc_array_t *: ((ar)->pp_elems[idx]), \
         vlc_array_t *: ((ar)->pp_elems[idx]))
 #else
-static inline void *vlc_array_item_at_index( vlc_array_t *ar, size_t idx )
+static inline void *vlc_array_get( vlc_array_t *ar, size_t idx )
 {
     return ar->pp_elems[idx];
 }
 
-static inline const void *vlc_array_item_at_index( const vlc_array_t *ar,
-                                                   size_t idx )
+static inline const void *vlc_array_get( const vlc_array_t *ar,
+                                         size_t idx )
 {
     return ar->pp_elems[idx];
 }
diff --git a/include/vlc_fingerprinter.h b/include/vlc_fingerprinter.h
index aba6d8e2b28..ac9b30b968d 100644
--- a/include/vlc_fingerprinter.h
+++ b/include/vlc_fingerprinter.h
@@ -62,7 +62,7 @@ static inline void fingerprint_request_Delete( fingerprint_request_t *p_f )
     input_item_Release( p_f->p_item );
     free( p_f->results.psz_fingerprint );
     for( size_t i = 0; i < vlc_array_count( & p_f->results.metas_array ); i++ )
-        vlc_meta_Delete( (vlc_meta_t *) vlc_array_item_at_index( & p_f->results.metas_array, i ) );
+        vlc_meta_Delete( (vlc_meta_t *) vlc_array_get( & p_f->results.metas_array, i ) );
     free( p_f );
 }
 
diff --git a/lib/event.c b/lib/event.c
index 8c64cacac32..2d5c3effc3f 100644
--- a/lib/event.c
+++ b/lib/event.c
@@ -94,7 +94,7 @@ void libvlc_event_manager_destroy(libvlc_event_manager_t *em)
     vlc_mutex_destroy(&em->lock);
 
     for (size_t i = 0; i < vlc_array_count(&em->listeners); i++)
-        free(vlc_array_item_at_index(&em->listeners, i));
+        free(vlc_array_get(&em->listeners, i));
 
     vlc_array_clear(&em->listeners);
 }
@@ -115,7 +115,7 @@ void libvlc_event_send( libvlc_event_manager_t * p_em,
     {
         libvlc_event_listener_t *listener;
 
-        listener = vlc_array_item_at_index(&p_em->listeners, i);
+        listener = vlc_array_get(&p_em->listeners, i);
         if (listener->event_type == p_event->type)
             listener->pf_callback(p_event, listener->p_user_data);
     }
@@ -168,7 +168,7 @@ void libvlc_event_detach(libvlc_event_manager_t *em, libvlc_event_type_t type,
     {
          libvlc_event_listener_t *listener;
 
-         listener = vlc_array_item_at_index(&em->listeners, i);
+         listener = vlc_array_get(&em->listeners, i);
 
          if (listener->event_type == type
           && listener->pf_callback == callback
diff --git a/lib/media_list.c b/lib/media_list.c
index 7c93e41d5f6..10d0bf6d022 100644
--- a/lib/media_list.c
+++ b/lib/media_list.c
@@ -199,7 +199,7 @@ void libvlc_media_list_release( libvlc_media_list_t * p_mlist )
 
     for( size_t i = 0; i < vlc_array_count( &p_mlist->items ); i++ )
     {
-        libvlc_media_t* p_md = vlc_array_item_at_index( &p_mlist->items, i );
+        libvlc_media_t* p_md = vlc_array_get( &p_mlist->items, i );
         libvlc_media_release( p_md );
     }
 
@@ -392,7 +392,7 @@ int libvlc_media_list_internal_remove_index( libvlc_media_list_t * p_mlist,
         return -1;
     }
 
-    p_md = vlc_array_item_at_index( &p_mlist->items, index );
+    p_md = vlc_array_get( &p_mlist->items, index );
 
     notify_item_deletion( p_mlist, p_md, index, EventWillHappen );
     vlc_array_remove( &p_mlist->items, index );
@@ -419,7 +419,7 @@ libvlc_media_list_item_at_index( libvlc_media_list_t * p_mlist,
         return NULL;
     }
 
-    p_md = vlc_array_item_at_index( &p_mlist->items, index );
+    p_md = vlc_array_get( &p_mlist->items, index );
     libvlc_media_retain( p_md );
     return p_md;
 }
diff --git a/modules/access/bluray.c b/modules/access/bluray.c
index ee82260fed2..fce88b9890b 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -939,7 +939,7 @@ typedef struct  fmt_es_pair {
 static int  findEsPairIndex(demux_sys_t *p_sys, int i_id)
 {
     for (size_t i = 0; i < vlc_array_count(&p_sys->es); ++i)
-        if (((fmt_es_pair_t*)vlc_array_item_at_index(&p_sys->es, i))->i_id == i_id)
+        if (((fmt_es_pair_t*)vlc_array_get(&p_sys->es, i))->i_id == i_id)
             return i;
 
     return -1;
@@ -948,7 +948,7 @@ static int  findEsPairIndex(demux_sys_t *p_sys, int i_id)
 static int  findEsPairIndexByEs(demux_sys_t *p_sys, es_out_id_t *p_es)
 {
     for (size_t i = 0; i < vlc_array_count(&p_sys->es); ++i)
-        if (((fmt_es_pair_t*)vlc_array_item_at_index(&p_sys->es, i))->p_es == p_es)
+        if (((fmt_es_pair_t*)vlc_array_get(&p_sys->es, i))->p_es == p_es)
             return i;
 
     return -1;
@@ -1076,7 +1076,7 @@ static void esOutDel(es_out_t *p_out, es_out_id_t *p_es)
 
     int idx = findEsPairIndexByEs(p_sys, p_es);
     if (idx >= 0) {
-        free(vlc_array_item_at_index(&p_sys->es, idx));
+        free(vlc_array_get(&p_sys->es, idx));
         vlc_array_remove(&p_sys->es, idx);
     }
     es_out_Del(es_out_sys->p_dst_out, p_es);
@@ -1096,7 +1096,7 @@ static void esOutDestroy(es_out_t *p_out)
     demux_sys_t *p_sys = p_demux->p_sys;
 
     for (size_t i = 0; i < vlc_array_count(&p_sys->es); ++i)
-        free(vlc_array_item_at_index(&p_sys->es, i));
+        free(vlc_array_get(&p_sys->es, i));
     vlc_array_clear(&p_sys->es);
     free(es_out_sys);
 }
@@ -2232,7 +2232,7 @@ static void blurayStreamSelect(demux_t *p_demux, uint32_t i_type, uint32_t i_id)
     if (i_pid > 0) {
         int i_idx = findEsPairIndex(p_sys, i_pid);
         if (i_idx >= 0) {
-            fmt_es_pair_t *p_pair = vlc_array_item_at_index(&p_sys->es, i_idx);
+            fmt_es_pair_t *p_pair = vlc_array_get(&p_sys->es, i_idx);
             assert(p_pair->p_es);
 
             if (i_type == BD_EVENT_PG_TEXTST_STREAM && !p_sys->b_spu_enable)
diff --git a/modules/access/dsm/sd.c b/modules/access/dsm/sd.c
index 2c006b8fda5..50821ac9b71 100644
--- a/modules/access/dsm/sd.c
+++ b/modules/access/dsm/sd.c
@@ -82,7 +82,7 @@ static void entry_item_remove( services_discovery_t *p_sd,
     {
         struct entry_item *p_entry_item;
 
-        p_entry_item = vlc_array_item_at_index( &p_sys->entry_item_list, i );
+        p_entry_item = vlc_array_get( &p_sys->entry_item_list, i );
         if( p_entry_item->p_entry == p_entry  )
         {
             services_discovery_RemoveItem( p_sd, p_entry_item->p_item );
@@ -177,7 +177,7 @@ void bdsm_SdClose (vlc_object_t *p_this)
     {
         struct entry_item *p_entry_item;
 
-        p_entry_item = vlc_array_item_at_index( &p_sys->entry_item_list, i );
+        p_entry_item = vlc_array_get( &p_sys->entry_item_list, i );
         input_item_Release( p_entry_item->p_item );
         free( p_entry_item );
     }
diff --git a/modules/access_output/livehttp.c b/modules/access_output/livehttp.c
index 17f080e35a6..0da61b6d281 100644
--- a/modules/access_output/livehttp.c
+++ b/modules/access_output/livehttp.c
@@ -522,7 +522,7 @@ static uint32_t segmentAmountNeeded( sout_access_out_sys_t *p_sys )
     float duration = .0f;
     for( size_t index = 1; index <= vlc_array_count( &p_sys->segments_t ); index++ )
     {
-        output_segment_t* segment = vlc_array_item_at_index( &p_sys->segments_t, vlc_array_count( &p_sys->segments_t ) - index );
+        output_segment_t* segment = vlc_array_get( &p_sys->segments_t, vlc_array_count( &p_sys->segments_t ) - index );
         duration += segment->f_seglength;
 
         if( duration >= (float)( 3 * p_sys->i_seglen ) )
@@ -547,10 +547,10 @@ static bool isFirstItemRemovable( sout_access_out_sys_t *p_sys, uint32_t i_first
      */
     for( unsigned int index = 0; index < i_index_offset; index++ )
     {
-        output_segment_t *segment = vlc_array_item_at_index( &p_sys->segments_t, p_sys->i_segment - i_firstseg + index );
+        output_segment_t *segment = vlc_array_get( &p_sys->segments_t, p_sys->i_segment - i_firstseg + index );
         duration += segment->f_seglength;
     }
-    output_segment_t *first = vlc_array_item_at_index( &p_sys->segments_t, 0 );
+    output_segment_t *first = vlc_array_get( &p_sys->segments_t, 0 );
 
     return duration >= (first->f_seglength + (float)(p_sys->i_numsegs * p_sys->i_seglen));
 }
@@ -612,7 +612,7 @@ static int updateIndexAndDel( sout_access_out_t *p_access, sout_access_out_sys_t
             //scale to i_index_offset..numsegs + i_index_offset
             uint32_t index = i - i_firstseg + i_index_offset;
 
-            output_segment_t *segment = vlc_array_item_at_index( &p_sys->segments_t, index );
+            output_segment_t *segment = vlc_array_get( &p_sys->segments_t, index );
             if( p_sys->key_uri &&
                 ( !psz_current_uri ||  strcmp( psz_current_uri, segment->psz_key_uri ) )
               )
@@ -688,7 +688,7 @@ static int updateIndexAndDel( sout_access_out_t *p_access, sout_access_out_sys_t
            isFirstItemRemovable( p_sys, i_firstseg, i_index_offset )
          )
     {
-         output_segment_t *segment = vlc_array_item_at_index( &p_sys->segments_t, 0 );
+         output_segment_t *segment = vlc_array_get( &p_sys->segments_t, 0 );
          msg_Dbg( p_access, "Removing segment number %d", segment->i_segment_number );
          vlc_array_remove( &p_sys->segments_t, 0 );
 
@@ -712,7 +712,7 @@ static void closeCurrentSegment( sout_access_out_t *p_access, sout_access_out_sy
 {
     if ( p_sys->i_handle >= 0 )
     {
-        output_segment_t *segment = vlc_array_item_at_index( &p_sys->segments_t, vlc_array_count( &p_sys->segments_t ) - 1 );
+        output_segment_t *segment = vlc_array_get( &p_sys->segments_t, vlc_array_count( &p_sys->segments_t ) - 1 );
 
         if( p_sys->key_uri )
         {
@@ -806,7 +806,7 @@ static void Close( vlc_object_t * p_this )
 
     while( vlc_array_count( &p_sys->segments_t ) > 0 )
     {
-        output_segment_t *segment = vlc_array_item_at_index( &p_sys->segments_t, 0 );
+        output_segment_t *segment = vlc_array_get( &p_sys->segments_t, 0 );
         vlc_array_remove( &p_sys->segments_t, 0 );
         if( p_sys->b_delsegs && p_sys->i_numsegs && segment->psz_filename )
         {
diff --git a/modules/codec/webvtt/subsvtt.c b/modules/codec/webvtt/subsvtt.c
index 27ff9fd72e1..785ff0fffe1 100644
--- a/modules/codec/webvtt/subsvtt.c
+++ b/modules/codec/webvtt/subsvtt.c
@@ -874,7 +874,7 @@ static void webvtt_domnode_SelectRuleNodes( decoder_t *p_dec, const vlc_css_rule
                                               i_playbacktime, &tempresults );
         }
         for( size_t i=0; i<vlc_array_count(&tempresults); i++ )
-            (void) vlc_array_append( p_results, vlc_array_item_at_index( &tempresults, i ) );
+            (void) vlc_array_append( p_results, vlc_array_get( &tempresults, i ) );
         vlc_array_clear( &tempresults );
     }
 }
@@ -1693,7 +1693,7 @@ static void ApplyCSSRules( decoder_t *p_dec, const vlc_css_rule_t *p_rule,
         {
             for( size_t i=0; i<vlc_array_count(&results); i++ )
             {
-                webvtt_dom_node_t *p_node = vlc_array_item_at_index( &results, i );
+                webvtt_dom_node_t *p_node = vlc_array_get( &results, i );
                 if( !webvtt_domnode_supportsCSSStyle( p_node ) )
                     continue;
 
@@ -1862,7 +1862,7 @@ static void Render( decoder_t *p_dec, vlc_tick_t i_start, vlc_tick_t i_stop )
     for( size_t i=0; i<timedtags.i_count; i++ )
     {
          const webvtt_dom_tag_t *p_tag =
-                 (const webvtt_dom_tag_t *) vlc_array_item_at_index( &timedtags, i );
+                 (const webvtt_dom_tag_t *) vlc_array_get( &timedtags, i );
          if( p_tag->i_start != i_substart ) /* might be duplicates */
          {
              if( i > 0 )
diff --git a/modules/control/dbus/dbus.c b/modules/control/dbus/dbus.c
index 56e84bb7627..39c3b12ac8d 100644
--- a/modules/control/dbus/dbus.c
+++ b/modules/control/dbus/dbus.c
@@ -319,7 +319,7 @@ static void Close   ( vlc_object_t *p_this )
     // Free the events array
     for( size_t i = 0; i < vlc_array_count( &p_sys->events ); i++ )
     {
-        callback_info_t* info = vlc_array_item_at_index( &p_sys->events, i );
+        callback_info_t* info = vlc_array_get( &p_sys->events, i );
         free( info );
     }
     vlc_mutex_destroy( &p_sys->lock );
@@ -389,7 +389,7 @@ static int next_timeout(intf_thread_t *intf)
 
     for (unsigned i = 0; i < count; i++)
     {
-        DBusTimeout *to = vlc_array_item_at_index(&sys->timeouts, i);
+        DBusTimeout *to = vlc_array_get(&sys->timeouts, i);
 
         if (!dbus_timeout_get_enabled(to))
             continue;
@@ -422,7 +422,7 @@ static void process_timeouts(intf_thread_t *intf)
 
     for (size_t i = 0; i < vlc_array_count(&sys->timeouts); i++)
     {
-        DBusTimeout *to = vlc_array_item_at_index(&sys->timeouts, i);
+        DBusTimeout *to = vlc_array_get(&sys->timeouts, i);
 
         if (!dbus_timeout_get_enabled(to))
             continue;
@@ -499,7 +499,7 @@ static int GetPollFds( intf_thread_t *p_intf, struct pollfd *p_fds )
     for( size_t i = 0; i < i_watches; i++ )
     {
         DBusWatch *p_watch = NULL;
-        p_watch = vlc_array_item_at_index( &p_sys->watches, i );
+        p_watch = vlc_array_get( &p_sys->watches, i );
         if( !dbus_watch_get_enabled( p_watch ) )
             continue;
 
@@ -822,7 +822,7 @@ static void *Run( void *data )
         DBusWatch *p_watches[i_watches ? i_watches : 1];
         for( size_t i = 0; i < i_watches; i++ )
         {
-            p_watches[i] = vlc_array_item_at_index( &p_sys->watches, i );
+            p_watches[i] = vlc_array_get( &p_sys->watches, i );
         }
 
         /* Get the list of events to process */
@@ -843,7 +843,7 @@ static void *Run( void *data )
                 if( pp_info )
                 {
                     for( size_t i = 0; i < i_events; i++ )
-                        pp_info[i] = vlc_array_item_at_index( &p_sys->events, i );
+                        pp_info[i] = vlc_array_get( &p_sys->events, i );
                     vlc_array_clear( &p_sys->events );
                 }
             }
@@ -894,7 +894,7 @@ static bool add_event_locked( intf_thread_t *p_intf, callback_info_t *p_info )
     for( size_t i = 0; i < vlc_array_count( &p_intf->p_sys->events ); ++ i )
     {
         callback_info_t *oldinfo =
-            vlc_array_item_at_index( &p_intf->p_sys->events, i );
+            vlc_array_get( &p_intf->p_sys->events, i );
         if( p_info->signal == oldinfo->signal )
         {
             free( p_info );
diff --git a/modules/gui/qt/dialogs/fingerprintdialog.cpp b/modules/gui/qt/dialogs/fingerprintdialog.cpp
index a8dc7f6b1dd..261503f462e 100644
--- a/modules/gui/qt/dialogs/fingerprintdialog.cpp
+++ b/modules/gui/qt/dialogs/fingerprintdialog.cpp
@@ -90,7 +90,7 @@ void FingerprintDialog::handleResults()
     for ( size_t i = 0; i< vlc_array_count( & p_r->results.metas_array ) ; i++ )
     {
         vlc_meta_t *p_meta =
-                (vlc_meta_t *) vlc_array_item_at_index( & p_r->results.metas_array, i );
+                (vlc_meta_t *) vlc_array_get( & p_r->results.metas_array, i );
         QListWidgetItem *item = new QListWidgetItem();
         ui->recordsList->addItem( item );
         QString mb_id( vlc_meta_GetExtra( p_meta, "musicbrainz-id" ) );
diff --git a/modules/misc/fingerprinter.c b/modules/misc/fingerprinter.c
index ade56a9319e..8233d72248a 100644
--- a/modules/misc/fingerprinter.c
+++ b/modules/misc/fingerprinter.c
@@ -94,7 +94,7 @@ static void QueueIncomingRequests( fingerprinter_sys_t *p_sys )
 
     for( size_t i = vlc_array_count( &p_sys->incoming.queue ); i > 0 ; i-- )
     {
-        fingerprint_request_t *r = vlc_array_item_at_index( &p_sys->incoming.queue, i - 1 );
+        fingerprint_request_t *r = vlc_array_get( &p_sys->incoming.queue, i - 1 );
         if( vlc_array_append( &p_sys->processing.queue, r ) )
             fingerprint_request_Delete( r );
     }
@@ -109,7 +109,7 @@ static fingerprint_request_t * GetResult( fingerprinter_thread_t *f )
     vlc_mutex_lock( &p_sys->results.lock );
     if ( vlc_array_count( &p_sys->results.queue ) )
     {
-        r = vlc_array_item_at_index( &p_sys->results.queue, 0 );
+        r = vlc_array_get( &p_sys->results.queue, 0 );
         vlc_array_remove( &p_sys->results.queue, 0 );
     }
     vlc_mutex_unlock( &p_sys->results.lock );
@@ -121,7 +121,7 @@ static void ApplyResult( fingerprint_request_t *p_r, size_t i_resultid )
     if ( i_resultid >= vlc_array_count( & p_r->results.metas_array ) ) return;
 
     vlc_meta_t *p_meta = (vlc_meta_t *)
-            vlc_array_item_at_index( & p_r->results.metas_array, i_resultid );
+            vlc_array_get( & p_r->results.metas_array, i_resultid );
     input_item_t *p_item = p_r->p_item;
     vlc_mutex_lock( &p_item->lock );
     vlc_meta_Merge( p_item->p_meta, p_meta );
@@ -277,18 +277,18 @@ static void Close(vlc_object_t *p_this)
 static void CleanSys( fingerprinter_sys_t *p_sys )
 {
     for ( size_t i = 0; i < vlc_array_count( &p_sys->incoming.queue ); i++ )
-        fingerprint_request_Delete( vlc_array_item_at_index( &p_sys->incoming.queue, i ) );
+        fingerprint_request_Delete( vlc_array_get( &p_sys->incoming.queue, i ) );
     vlc_array_clear( &p_sys->incoming.queue );
     vlc_mutex_destroy( &p_sys->incoming.lock );
 
     for ( size_t i = 0; i < vlc_array_count( &p_sys->processing.queue ); i++ )
-        fingerprint_request_Delete( vlc_array_item_at_index( &p_sys->processing.queue, i ) );
+        fingerprint_request_Delete( vlc_array_get( &p_sys->processing.queue, i ) );
     vlc_array_clear( &p_sys->processing.queue );
     vlc_mutex_destroy( &p_sys->processing.lock );
     vlc_cond_destroy( &p_sys->processing.cond );
 
     for ( size_t i = 0; i < vlc_array_count( &p_sys->results.queue ); i++ )
-        fingerprint_request_Delete( vlc_array_item_at_index( &p_sys->results.queue, i ) );
+        fingerprint_request_Delete( vlc_array_get( &p_sys->results.queue, i ) );
     vlc_array_clear( &p_sys->results.queue );
     vlc_mutex_destroy( &p_sys->results.lock );
 }
@@ -338,7 +338,7 @@ static void *Run( void *opaque )
         while( vlc_array_count( &p_sys->processing.queue ) )
         {
             int canc = vlc_savecancel();
-            fingerprint_request_t *p_data = vlc_array_item_at_index( &p_sys->processing.queue, 0 );
+            fingerprint_request_t *p_data = vlc_array_get( &p_sys->processing.queue, 0 );
 
             char *psz_uri = input_item_GetURI( p_data->p_item );
             if ( psz_uri != NULL )
diff --git a/modules/mux/asf.c b/modules/mux/asf.c
index f236651a4c7..f60e37e01eb 100644
--- a/modules/mux/asf.c
+++ b/modules/mux/asf.c
@@ -279,7 +279,7 @@ static void Close( vlc_object_t * p_this )
 
     for( size_t i = 0; i < vlc_array_count( &p_sys->tracks ); i++ )
     {
-        asf_track_t *track = vlc_array_item_at_index( &p_sys->tracks, i );
+        asf_track_t *track = vlc_array_get( &p_sys->tracks, i );
         free( track->p_extra );
         es_format_Clean( &track->fmt );
         free( track );
@@ -865,7 +865,7 @@ static block_t *asf_header_create( sout_mux_t *p_mux, bool b_broadcast )
     i_ci_size = 44;
     for( size_t i = 0; i < vlc_array_count( &p_sys->tracks ); i++ )
     {
-        tk = vlc_array_item_at_index( &p_sys->tracks, i );
+        tk = vlc_array_get( &p_sys->tracks, i );
         /* update also track-id */
         tk->i_id = i + 1;
 
@@ -894,7 +894,7 @@ static block_t *asf_header_create( sout_mux_t *p_mux, bool b_broadcast )
     /* size of the metadata object */
     for( size_t i = 0; i < vlc_array_count( &p_sys->tracks ); i++ )
     {
-        const asf_track_t *p_track = vlc_array_item_at_index( &p_sys->tracks, i );
+        const asf_track_t *p_track = vlc_array_get( &p_sys->tracks, i );
         if( p_track->i_cat == VIDEO_ES &&
             p_track->fmt.video.i_sar_num != 0 &&
             p_track->fmt.video.i_sar_den != 0 )
@@ -961,7 +961,7 @@ static block_t *asf_header_create( sout_mux_t *p_mux, bool b_broadcast )
     /* extended stream properties */
     for( size_t i = 0; i < vlc_array_count( &p_sys->tracks ); i++ )
     {
-        const asf_track_t *p_track = vlc_array_item_at_index( &p_sys->tracks, i );
+        const asf_track_t *p_track = vlc_array_get( &p_sys->tracks, i );
         const es_format_t *p_fmt = &p_track->fmt;
 
         if( !p_track->b_extended )
@@ -1000,7 +1000,7 @@ static block_t *asf_header_create( sout_mux_t *p_mux, bool b_broadcast )
         asf_track_t *tk = NULL;
         for( size_t i = 0; i < vlc_array_count( &p_sys->tracks ); i++ )
         {
-            tk = vlc_array_item_at_index( &p_sys->tracks, i );
+            tk = vlc_array_get( &p_sys->tracks, i );
             if( tk->i_cat == VIDEO_ES &&
                 tk->fmt.video.i_sar_num != 0 &&
                 tk->fmt.video.i_sar_den != 0 )
@@ -1057,7 +1057,7 @@ static block_t *asf_header_create( sout_mux_t *p_mux, bool b_broadcast )
     /* stream properties */
     for( size_t i = 0; i < vlc_array_count( &p_sys->tracks ); i++ )
     {
-        tk = vlc_array_item_at_index( &p_sys->tracks, i);
+        tk = vlc_array_get( &p_sys->tracks, i);
 
         bo_add_guid ( &bo, &asf_object_stream_properties_guid );
         bo_addle_u64( &bo, 78 + tk->i_extra + (tk->b_audio_correction ? 8:0) );
@@ -1101,7 +1101,7 @@ static block_t *asf_header_create( sout_mux_t *p_mux, bool b_broadcast )
     bo_addle_u32( &bo, vlc_array_count( &p_sys->tracks ) );
     for( size_t i = 0; i < vlc_array_count( &p_sys->tracks ); i++ )
     {
-        tk = vlc_array_item_at_index( &p_sys->tracks ,i);
+        tk = vlc_array_get( &p_sys->tracks ,i);
 
         if( tk->i_cat == VIDEO_ES ) bo_addle_u16( &bo, 1 /* video */ );
         else if( tk->i_cat == AUDIO_ES ) bo_addle_u16( &bo, 2 /* audio */ );
diff --git a/modules/services_discovery/microdns.c b/modules/services_discovery/microdns.c
index 135b627eba4..df02a6d1312 100644
--- a/modules/services_discovery/microdns.c
+++ b/modules/services_discovery/microdns.c
@@ -235,7 +235,7 @@ items_exists( struct discovery_sys *p_sys, const char *psz_uri )
 {
     for( size_t i = 0; i < vlc_array_count( &p_sys->items ); ++i )
     {
-        struct item *p_item = vlc_array_item_at_index( &p_sys->items, i );
+        struct item *p_item = vlc_array_get( &p_sys->items, i );
         if( strcmp( p_item->psz_uri, psz_uri ) == 0 )
         {
             p_item->i_last_seen = vlc_tick_now();
@@ -255,7 +255,7 @@ items_timeout( struct discovery_sys *p_sys, services_discovery_t *p_sd,
     /* Remove items that are not seen since TIMEOUT */
     for( size_t i = 0; i < vlc_array_count( &p_sys->items ); ++i )
     {
-        struct item *p_item = vlc_array_item_at_index( &p_sys->items, i );
+        struct item *p_item = vlc_array_get( &p_sys->items, i );
         if( i_now - p_item->i_last_seen > TIMEOUT )
         {
             if( p_sd != NULL )
@@ -273,7 +273,7 @@ items_clear( struct discovery_sys *p_sys )
 {
     for( size_t i = 0; i < vlc_array_count( &p_sys->items ); ++i )
     {
-        struct item *p_item = vlc_array_item_at_index( &p_sys->items, i );
+        struct item *p_item = vlc_array_get( &p_sys->items, i );
         items_release( p_sys, p_item );
     }
     vlc_array_clear( &p_sys->items );
diff --git a/src/input/mrl_helpers.h b/src/input/mrl_helpers.h
index c7482aac119..1415e9f9b68 100644
--- a/src/input/mrl_helpers.h
+++ b/src/input/mrl_helpers.h
@@ -154,7 +154,7 @@ mrl_FragmentSplit( vlc_array_t* out_items,
 
 error:
     for( size_t i = 0; i < vlc_array_count( out_items ); ++i )
-        free( vlc_array_item_at_index( out_items, i ) );
+        free( vlc_array_get( out_items, i ) );
     vlc_array_clear( out_items );
     return VLC_EGENERIC;;
 }
diff --git a/src/input/stream_extractor.c b/src/input/stream_extractor.c
index 7ccc4b6296a..c590411deb3 100644
--- a/src/input/stream_extractor.c
+++ b/src/input/stream_extractor.c
@@ -351,7 +351,7 @@ stream_extractor_AttachParsed( stream_t** source, char const* data,
 
     while( idx < count )
     {
-        char* id = vlc_array_item_at_index( &identifiers, idx );
+        char* id = vlc_array_get( &identifiers, idx );
 
         if( vlc_stream_extractor_Attach( source, id, NULL ) )
             break;
@@ -360,7 +360,7 @@ stream_extractor_AttachParsed( stream_t** source, char const* data,
     }
 
     for( size_t i = 0; i < count; ++i )
-        free( vlc_array_item_at_index( &identifiers, i ) );
+        free( vlc_array_get( &identifiers, i ) );
     vlc_array_clear( &identifiers );
 
     return idx == count ? VLC_SUCCESS : VLC_EGENERIC;
diff --git a/src/interface/dialog.c b/src/interface/dialog.c
index 459c41602b5..94c8caabfaf 100644
--- a/src/interface/dialog.c
+++ b/src/interface/dialog.c
@@ -228,7 +228,7 @@ dialog_clear_all_locked(vlc_dialog_provider *p_provider)
     for (size_t i = 0; i < vlc_array_count(&p_provider->dialog_array); ++i)
     {
         vlc_dialog_id *p_id =
-            vlc_array_item_at_index(&p_provider->dialog_array, i);
+            vlc_array_get(&p_provider->dialog_array, i);
         dialog_cancel_locked(p_provider, p_id);
     }
 }
diff --git a/src/misc/background_worker.c b/src/misc/background_worker.c
index 2f21e5006a3..84ec819c38c 100644
--- a/src/misc/background_worker.c
+++ b/src/misc/background_worker.c
@@ -68,7 +68,7 @@ static void* Thread( void* data )
         {
             if( vlc_array_count( &worker->tail.data ) )
             {
-                item = vlc_array_item_at_index( &worker->tail.data, 0 );
+                item = vlc_array_get( &worker->tail.data, 0 );
                 handle = NULL;
 
                 vlc_array_remove( &worker->tail.data, 0 );
@@ -157,7 +157,7 @@ static void BackgroundWorkerCancel( struct background_worker* worker, void* id)
     for( size_t i = 0; i < vlc_array_count( &worker->tail.data ); )
     {
         struct bg_queued_item* item =
-            vlc_array_item_at_index( &worker->tail.data, i );
+            vlc_array_get( &worker->tail.data, i );
 
         if( id == NULL || item->id == id )
         {
diff --git a/src/misc/httpcookies.c b/src/misc/httpcookies.c
index 77ab852b157..af6e23dc71d 100644
--- a/src/misc/httpcookies.c
+++ b/src/misc/httpcookies.c
@@ -287,7 +287,7 @@ void vlc_http_cookies_destroy( vlc_http_cookie_jar_t * p_jar )
         return;
 
     for( size_t i = 0; i < vlc_array_count( &p_jar->cookies ); i++ )
-        cookie_destroy( vlc_array_item_at_index( &p_jar->cookies, i ) );
+        cookie_destroy( vlc_array_get( &p_jar->cookies, i ) );
 
     vlc_array_clear( &p_jar->cookies );
     vlc_mutex_destroy( &p_jar->lock );
@@ -322,7 +322,7 @@ bool vlc_http_cookies_store(vlc_http_cookie_jar_t *p_jar, const char *cookies,
 
     for( size_t i = 0; i < vlc_array_count( &p_jar->cookies ); i++ )
     {
-        http_cookie_t *iter = vlc_array_item_at_index( &p_jar->cookies, i );
+        http_cookie_t *iter = vlc_array_get( &p_jar->cookies, i );
 
         assert( iter->psz_name );
         assert( iter->psz_domain );
@@ -359,7 +359,7 @@ char *vlc_http_cookies_fetch(vlc_http_cookie_jar_t *p_jar, bool secure,
 
     for( size_t i = 0; i < vlc_array_count( &p_jar->cookies ); i++ )
     {
-        const http_cookie_t * cookie = vlc_array_item_at_index( &p_jar->cookies, i );
+        const http_cookie_t * cookie = vlc_array_get( &p_jar->cookies, i );
         if (cookie_should_be_sent(cookie, secure, host, path))
         {
             char *psz_updated_buf = NULL;
diff --git a/src/stream_output/stream_output.c b/src/stream_output/stream_output.c
index 18aabd7227a..363b6f7df64 100644
--- a/src/stream_output/stream_output.c
+++ b/src/stream_output/stream_output.c
@@ -872,8 +872,8 @@ sout_stream_t *sout_StreamChainNew(sout_instance_t *p_sout, const char *psz_chai
     vlc_array_init(&module);
     while(i--)
     {
-        p_next = sout_StreamNew( p_sout, vlc_array_item_at_index(&name, i),
-            vlc_array_item_at_index(&cfg, i), p_next);
+        p_next = sout_StreamNew( p_sout, vlc_array_get(&name, i),
+            vlc_array_get(&cfg, i), p_next);
 
         if(!p_next)
             goto error;
@@ -897,15 +897,15 @@ error:
     /* destroy all modules created, starting with the last one */
     int modules = vlc_array_count(&module);
     while(modules--)
-        sout_StreamDelete(vlc_array_item_at_index(&module, modules));
+        sout_StreamDelete(vlc_array_get(&module, modules));
     vlc_array_clear(&module);
 
     /* then destroy all names and config which weren't destroyed by
      * sout_StreamDelete */
     while(i--)
     {
-        free(vlc_array_item_at_index(&name, i));
-        config_ChainDestroy(vlc_array_item_at_index(&cfg, i));
+        free(vlc_array_get(&name, i));
+        config_ChainDestroy(vlc_array_get(&cfg, i));
     }
     vlc_array_clear(&name);
     vlc_array_clear(&cfg);
diff --git a/src/test/mrl_helpers.c b/src/test/mrl_helpers.c
index 3439116fecf..4e220d49d0e 100644
--- a/src/test/mrl_helpers.c
+++ b/src/test/mrl_helpers.c
@@ -85,7 +85,7 @@ int main (void)
             for (size_t j = 0; testcase[i].results[j] != NULL; ++j)
             {
                 assert(j < vlc_array_count(&out) && j < MAX_RESULT);
-                char *res = vlc_array_item_at_index(&out, j);
+                char *res = vlc_array_get(&out, j);
 
                 assert(strcmp(testcase[i].results[j], res) == 0);
 
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 5db7acf5091..71d59522dd0 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -783,7 +783,7 @@ static void ThreadChangeFilters(vout_thread_t *vout,
 
         filter_chain_Reset(chain, p_fmt_current, p_fmt_current);
         for (size_t i = 0; i < vlc_array_count(array); i++) {
-            vout_filter_t *e = vlc_array_item_at_index(array, i);
+            vout_filter_t *e = vlc_array_get(array, i);
             msg_Dbg(vout, "Adding '%s' as %s", e->name, a == 0 ? "static" : "interactive");
             filter_t *filter = filter_chain_AppendFilter(chain, e->name, e->cfg,
                                NULL, NULL);
-- 
2.18.0



More information about the vlc-devel mailing list