[vlc-commits] input: add explicit input_item_node_RemoveNode()

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


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

input: add explicit input_item_node_RemoveNode()

This is rarely used (only once in the whole code base).

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

 include/vlc_input_item.h |  6 ++++++
 src/input/access.c       |  2 ++
 src/input/item.c         | 11 ++++++++---
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/include/vlc_input_item.h b/include/vlc_input_item.h
index c593d65e20..bd6a8fd8d8 100644
--- a/include/vlc_input_item.h
+++ b/include/vlc_input_item.h
@@ -204,6 +204,12 @@ VLC_API input_item_node_t * input_item_node_AppendItem( input_item_node_t *p_nod
 VLC_API void input_item_node_AppendNode( input_item_node_t *p_parent, input_item_node_t *p_child );
 
 /**
+ * Remove a node from its parent.
+ */
+void input_item_node_RemoveNode( input_item_node_t *parent,
+                                 input_item_node_t *child );
+
+/**
  * Delete a node created with input_item_node_Create() and all its children.
  */
 VLC_API void input_item_node_Delete( input_item_node_t *p_node );
diff --git a/src/input/access.c b/src/input/access.c
index 8986a25edf..7fca5cff17 100644
--- a/src/input/access.c
+++ b/src/input/access.c
@@ -617,6 +617,8 @@ static void fsdir_attach_slaves(struct access_fsdir *p_fsdir)
              * added in the parent node */
             if (p_fsdir_slave->p_node != NULL)
             {
+                input_item_node_RemoveNode(p_fsdir->p_node,
+                                           p_fsdir_slave->p_node);
                 input_item_node_Delete(p_fsdir_slave->p_node);
                 p_fsdir_slave->p_node = NULL;
             }
diff --git a/src/input/item.c b/src/input/item.c
index 41a2b98b77..07d980ebc7 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -1261,9 +1261,7 @@ static void RecursiveNodeDelete( input_item_node_t *p_node )
 void input_item_node_Delete( input_item_node_t *p_node )
 {
     if( p_node->p_parent )
-        TAB_REMOVE(p_node->p_parent->i_children, p_node->p_parent->pp_children,
-                   p_node);
-
+        input_item_node_RemoveNode(node->p_parent, node);
     RecursiveNodeDelete( p_node );
 }
 
@@ -1294,6 +1292,13 @@ void input_item_node_AppendNode( input_item_node_t *p_parent, input_item_node_t
     p_child->p_parent = p_parent;
 }
 
+void input_item_node_RemoveNode( input_item_node_t *parent,
+                                 input_item_node_t *child )
+{
+    TAB_REMOVE(parent->i_children, parent->pp_children, child);
+    child->p_parent = NULL;
+}
+
 void input_item_node_PostAndDelete( input_item_node_t *p_root )
 {
     vlc_event_send( &p_root->p_item->event_manager, &(vlc_event_t) {



More information about the vlc-commits mailing list