+ /* Attach the parent to its child */
+ p_this->p_parent = p_parent;
+
+ /* Attach the child to its parent */
+ INSERT_ELEM( p_parent->pp_children, p_parent->i_children,
+ p_parent->i_children, p_this );
+
+ /* Climb up the tree to see whether we are connected with the root */
+ if( p_parent->b_attached )
+ {
+ SetAttachment( p_this, VLC_TRUE );
+ }
+
+ vlc_mutex_unlock( &structure_lock );
+}
+
+/**
+ ****************************************************************************
+ * detach object from its parent
+ *****************************************************************************
+ * This function removes all links between an object and its parent.
+ *****************************************************************************/
+void __vlc_object_detach( vlc_object_t *p_this )
+{
+ vlc_mutex_lock( &structure_lock );
+ if( !p_this->p_parent )
+ {
+ msg_Err( p_this, "object is not attached" );
+ vlc_mutex_unlock( &structure_lock );
+ return;
+ }
+
+ /* Climb up the tree to see whether we are connected with the root */
+ if( p_this->p_parent->b_attached )
+ {
+ SetAttachment( p_this, VLC_FALSE );
+ }
+
+ DetachObject( p_this );
+ vlc_mutex_unlock( &structure_lock );
+}
+
+/**
+ ****************************************************************************
+ * find a list typed objects and increment their refcount
+ *****************************************************************************
+ * This function recursively looks for a given object type. i_mode can be one
+ * of FIND_PARENT, FIND_CHILD or FIND_ANYWHERE.
+ *****************************************************************************/
+vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode )
+{
+ vlc_list_t *p_list;
+ vlc_object_t **pp_current, **pp_end;
+ int i_count = 0, i_index = 0;
+
+ vlc_mutex_lock( &structure_lock );
+
+ /* Look for the objects */