[vlc-devel] commit: input_item_node_Delete: fix leakage and lessen complexity ( Jakob Leben )
git version control
git at videolan.org
Tue Feb 2 08:38:18 CET 2010
vlc | branch: master | Jakob Leben <jleben at videolan.org> | Tue Feb 2 08:31:42 2010 +0100| [5f4912046e026cca161a42a99de5e1f8fa31b04c] | committer: Jakob Leben
input_item_node_Delete: fix leakage and lessen complexity
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5f4912046e026cca161a42a99de5e1f8fa31b04c
---
src/input/item.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/input/item.c b/src/input/item.c
index a16cf79..454aba1 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -998,15 +998,21 @@ input_item_node_t *input_item_node_Create( input_item_t *p_input )
return p_node;
}
-void input_item_node_Delete( input_item_node_t *p_node )
+static void RecursiveNodeDelete( input_item_node_t *p_node )
{
- int i;
- for( i = 0; i < p_node->i_children; i++ )
- input_item_node_Delete( p_node->pp_children[i] );
+ for( int i = 0; i < p_node->i_children; i++ )
+ RecursiveNodeDelete( p_node->pp_children[i] );
+
+ vlc_gc_decref( p_node->p_item );
+ free( p_node->pp_children );
+ free( p_node );
+}
+void input_item_node_Delete( input_item_node_t *p_node )
+{
if( p_node->p_parent )
{
- for( i = 0; i < p_node->p_parent->i_children; i++ )
+ for( int i = 0; i < p_node->p_parent->i_children; i++ )
if( p_node->p_parent->pp_children[i] == p_node )
{
REMOVE_ELEM( p_node->p_parent->pp_children,
@@ -1016,8 +1022,7 @@ void input_item_node_Delete( input_item_node_t *p_node )
}
}
- vlc_gc_decref( p_node->p_item );
- free( p_node );
+ RecursiveNodeDelete( p_node );
}
input_item_node_t *input_item_node_AppendItem( input_item_node_t *p_node, input_item_t *p_item )
More information about the vlc-devel
mailing list