[vlc-commits] playlist: inline playlist_NodeRemoveItem()

Rémi Denis-Courmont git at videolan.org
Tue Nov 15 22:19:39 CET 2016


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Nov 15 23:10:15 2016 +0200| [3f81cf7e6ed1f8dc61b398b856c45e9547e32d43] | committer: Rémi Denis-Courmont

playlist: inline playlist_NodeRemoveItem()

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

 include/vlc_playlist.h |  1 -
 src/libvlccore.sym     |  1 -
 src/playlist/tree.c    | 48 ++++++++++++------------------------------------
 3 files changed, 12 insertions(+), 38 deletions(-)

diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h
index 323897e..6ff7f3d 100644
--- a/include/vlc_playlist.h
+++ b/include/vlc_playlist.h
@@ -363,7 +363,6 @@ VLC_API int playlist_LiveSearchUpdate(playlist_t *, playlist_item_t *, const cha
 VLC_API playlist_item_t * playlist_NodeCreate( playlist_t *, const char *, playlist_item_t * p_parent, int i_pos, int i_flags, input_item_t * );
 VLC_API int playlist_NodeAppend(playlist_t *,playlist_item_t*,playlist_item_t *);
 VLC_API int playlist_NodeInsert(playlist_t *,playlist_item_t*,playlist_item_t *, int);
-VLC_API int playlist_NodeRemoveItem(playlist_t *,playlist_item_t*,playlist_item_t *);
 VLC_API playlist_item_t * playlist_ChildSearchName(playlist_item_t*, const char* ) VLC_USED;
 VLC_API void playlist_NodeDelete( playlist_t *, playlist_item_t *, bool , bool );
 
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index fbb2b85..6da7907 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -357,7 +357,6 @@ playlist_NodeAppend
 playlist_NodeCreate
 playlist_NodeDelete
 playlist_NodeInsert
-playlist_NodeRemoveItem
 playlist_RecursiveNodeSort
 playlist_ServicesDiscoveryAdd
 playlist_ServicesDiscoveryControl
diff --git a/src/playlist/tree.c b/src/playlist/tree.c
index 617b94b..78350ab 100644
--- a/src/playlist/tree.c
+++ b/src/playlist/tree.c
@@ -178,8 +178,18 @@ void playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root,
     PL_DEBUG( "deleting item `%s'", p_root->p_input->psz_name );
 
     /* Remove the item from its parent */
-    if( p_root->p_parent )
-        playlist_NodeRemoveItem( p_playlist, p_root, p_root->p_parent );
+    playlist_item_t *p_parent = p_root->p_parent;
+    if( p_parent != NULL )
+    {
+        for( int i = 0; i < p_parent->i_children ; i++ )
+        {
+            if( p_parent->pp_children[i] == p_root )
+            {
+                REMOVE_ELEM( p_parent->pp_children, p_parent->i_children, i );
+                assert( p_root->p_parent == p_parent );
+            }
+        }
+    }
 
     playlist_ItemRelease( p_root );
 }
@@ -225,40 +235,6 @@ int playlist_NodeInsert( playlist_t *p_playlist,
 }
 
 /**
- * Deletes an item from the children of a node
- *
- * \param p_playlist the playlist
- * \param p_item the item to remove
- * \param p_parent the parent node
- * \return VLC_SUCCESS or an error
- */
-int playlist_NodeRemoveItem( playlist_t *p_playlist,
-                        playlist_item_t *p_item,
-                        playlist_item_t *p_parent )
-{
-    PL_ASSERT_LOCKED;
-    (void)p_playlist;
-
-    int ret = VLC_EGENERIC;
-
-    for(int i= 0; i< p_parent->i_children ; i++ )
-    {
-        if( p_parent->pp_children[i] == p_item )
-        {
-            REMOVE_ELEM( p_parent->pp_children, p_parent->i_children, i );
-            ret = VLC_SUCCESS;
-        }
-    }
-
-    if( ret == VLC_SUCCESS ) {
-        assert( p_item->p_parent == p_parent );
-        p_item->p_parent = NULL;
-    }
-
-    return ret;
-}
-
-/**
  * Search a child of a node by its name
  *
  * \param p_node the node



More information about the vlc-commits mailing list