[vlc-commits] playlist: make item deletion function return void

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:04:14 2016 +0200| [f293153157b40a93f43b1b43c4967e149c9ba9cb] | committer: Rémi Denis-Courmont

playlist: make item deletion function return void

...where applicable. (Some other functions conditionally delete stuff;
those functions can actually fail.)

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

 include/vlc_playlist.h           |  2 +-
 src/playlist/item.c              | 10 +++++-----
 src/playlist/playlist_internal.h |  4 ++--
 src/playlist/tree.c              | 20 +++++++-------------
 4 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h
index 9fc237c..323897e 100644
--- a/include/vlc_playlist.h
+++ b/include/vlc_playlist.h
@@ -365,7 +365,7 @@ 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 int playlist_NodeDelete( playlist_t *, playlist_item_t *, bool , bool );
+VLC_API void playlist_NodeDelete( playlist_t *, playlist_item_t *, bool , bool );
 
 VLC_API playlist_item_t * playlist_GetNextLeaf( playlist_t *p_playlist, playlist_item_t *p_root, playlist_item_t *p_item, bool b_ena, bool b_unplayed ) VLC_USED;
 VLC_API playlist_item_t * playlist_GetPrevLeaf( playlist_t *p_playlist, playlist_item_t *p_root, playlist_item_t *p_item, bool b_ena, bool b_unplayed ) VLC_USED;
diff --git a/src/playlist/item.c b/src/playlist/item.c
index 50ea1c2..6bd3655 100644
--- a/src/playlist/item.c
+++ b/src/playlist/item.c
@@ -300,9 +300,8 @@ playlist_item_t *playlist_ItemNewFromInput( playlist_t *p_playlist,
  * Release an item
  *
  * \param p_item item to delete
- * \return VLC_SUCCESS
 */
-int playlist_ItemRelease( playlist_item_t *p_item )
+void playlist_ItemRelease( playlist_item_t *p_item )
 {
     /* For the assert */
     playlist_t *p_playlist = p_item->p_playlist;
@@ -312,7 +311,6 @@ int playlist_ItemRelease( playlist_item_t *p_item )
     free( p_item->pp_children );
     vlc_gc_decref( p_item->p_input );
     free( p_item );
-    return VLC_SUCCESS;
 }
 
 /**
@@ -331,7 +329,8 @@ static int DeleteFromInput( playlist_t *p_playlist, input_item_t *p_input,
     playlist_item_t *p_item = playlist_ItemFindFromInputAndRoot(
         p_playlist, p_input, p_root, false );
     if( !p_item ) return VLC_EGENERIC;
-    return playlist_NodeDelete( p_playlist, p_item, true, false );
+    playlist_NodeDelete( p_playlist, p_item, true, false );
+    return VLC_SUCCESS;
 }
 
 /**
@@ -402,7 +401,8 @@ int playlist_DeleteFromItemId( playlist_t *p_playlist, int i_id )
     PL_ASSERT_LOCKED;
     playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id );
     if( !p_item ) return VLC_EGENERIC;
-    return playlist_NodeDelete( p_playlist, p_item, true, false );
+    playlist_NodeDelete( p_playlist, p_item, true, false );
+    return VLC_SUCCESS;
 }
 
 /***************************************************************************
diff --git a/src/playlist/playlist_internal.h b/src/playlist/playlist_internal.h
index a9a0bc0..aec656e 100644
--- a/src/playlist/playlist_internal.h
+++ b/src/playlist/playlist_internal.h
@@ -134,9 +134,9 @@ playlist_item_t *playlist_ItemFindFromInputAndRoot( playlist_t *p_playlist,
 int playlist_DeleteFromInputInParent( playlist_t *, input_item_t *,
                                       playlist_item_t *, bool );
 int playlist_DeleteFromItemId( playlist_t*, int );
-int playlist_ItemRelease( playlist_item_t * );
+void playlist_ItemRelease( playlist_item_t * );
 
-int playlist_NodeEmpty( playlist_t *, playlist_item_t *, bool );
+void playlist_NodeEmpty( playlist_t *, playlist_item_t *, bool );
 
 void ResetCurrentlyPlaying( playlist_t *p_playlist, playlist_item_t *p_cur );
 void ResyncCurrentIndex( playlist_t *p_playlist, playlist_item_t *p_cur );
diff --git a/src/playlist/tree.c b/src/playlist/tree.c
index d67d373..617b94b 100644
--- a/src/playlist/tree.c
+++ b/src/playlist/tree.c
@@ -99,20 +99,17 @@ playlist_item_t * playlist_NodeCreate( playlist_t *p_playlist,
  * \param p_playlist the playlist
  * \param p_root the node
  * \param b_delete_items do we have to delete the children items ?
- * \return VLC_SUCCESS or an error
  */
-int playlist_NodeEmpty( playlist_t *p_playlist, playlist_item_t *p_root,
+void playlist_NodeEmpty( playlist_t *p_playlist, playlist_item_t *p_root,
                         bool b_delete_items )
 {
     PL_ASSERT_LOCKED;
-    int i;
+
     if( p_root->i_children == -1 )
-    {
-        return VLC_EGENERIC;
-    }
+        return;
 
     /* Delete the children */
-    for( i =  p_root->i_children-1 ; i >= 0 ;i-- )
+    for( int i = p_root->i_children-1 ; i >= 0 ;i-- )
     {
         if( p_root->pp_children[i]->i_children > -1 )
         {
@@ -126,7 +123,6 @@ int playlist_NodeEmpty( playlist_t *p_playlist, playlist_item_t *p_root,
                                        p_root->pp_children[i]->i_id );
         }
     }
-    return VLC_SUCCESS;
 }
 
 /**
@@ -135,10 +131,9 @@ int playlist_NodeEmpty( playlist_t *p_playlist, playlist_item_t *p_root,
  * \param p_playlist the playlist
  * \param p_root the node
  * \param b_delete_items do we have to delete the children items ?
- * \return VLC_SUCCESS or an error
  */
-int playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root,
-                         bool b_delete_items, bool b_force )
+void playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root,
+                          bool b_delete_items, bool b_force )
 {
     PL_ASSERT_LOCKED;
 
@@ -150,7 +145,7 @@ int playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root,
 
     /* Delete the node */
     if( p_root->i_flags & PLAYLIST_RO_FLAG && !b_force )
-        return VLC_SUCCESS;
+        return;
 
     pl_priv(p_playlist)->b_reset_currently_playing = true;
 
@@ -187,7 +182,6 @@ int playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root,
         playlist_NodeRemoveItem( p_playlist, p_root, p_root->p_parent );
 
     playlist_ItemRelease( p_root );
-    return VLC_SUCCESS;
 }
 
 



More information about the vlc-commits mailing list