[vlc-commits] Remove unused FIND_PARENT

Rémi Denis-Courmont git at videolan.org
Wed May 25 19:29:42 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed May 25 18:52:10 2011 +0300| [9d002286825ad14302ab75d7c848e4933c0567d6] | committer: Rémi Denis-Courmont

Remove unused FIND_PARENT

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

 include/vlc_objects.h      |    1 -
 modules/lua/libs/objects.c |    4 +-
 share/lua/README.txt       |    7 ++---
 src/misc/objects.c         |   55 ++++++++++---------------------------------
 4 files changed, 18 insertions(+), 49 deletions(-)

diff --git a/include/vlc_objects.h b/include/vlc_objects.h
index 7fe95d5..f6ac421 100644
--- a/include/vlc_objects.h
+++ b/include/vlc_objects.h
@@ -41,7 +41,6 @@
 #define VLC_OBJECT_GENERIC     (-666)
 
 /* Object search mode */
-#define FIND_PARENT         0x0001
 #define FIND_CHILD          0x0002
 #define FIND_ANYWHERE       0x0003
 
diff --git a/modules/lua/libs/objects.c b/modules/lua/libs/objects.c
index b412850..96905c0 100644
--- a/modules/lua/libs/objects.c
+++ b/modules/lua/libs/objects.c
@@ -89,8 +89,7 @@ static int vlc_object_search_mode_from_string( const char *psz_name )
         int i_mode;
         const char *psz_name;
     } pp_modes[] =
-        { { FIND_PARENT, "parent" },
-          { FIND_CHILD, "child" },
+        { { FIND_CHILD, "child" },
           { FIND_ANYWHERE, "anywhere" },
           { 0, "" } };
     int i;
@@ -114,6 +113,7 @@ static int vlclua_object_find_name( lua_State *L )
     const char *psz_mode = luaL_checkstring( L, 3 );
 
     vlc_object_t *p_this;
+
     int i_mode = vlc_object_search_mode_from_string( psz_mode );
     vlc_object_t *p_result;
 
diff --git a/share/lua/README.txt b/share/lua/README.txt
index 9714109..15b2115 100644
--- a/share/lua/README.txt
+++ b/share/lua/README.txt
@@ -223,10 +223,9 @@ object.playlist(): Get the playlist object.
 object.libvlc(): Get the libvlc object.
 
 object.find( object, type, mode ): Find an object of given type. mode can
-  be any of "parent", "child" and "anywhere". If set to "parent", it will
-  look in "object"'s parent objects. If set to "child" it will look in
-  "object"'s children. If set to "anywhere", it will look in all the
-  objects. If object is unset, the current module's object will be used.
+  be "child" and "anywhere". If set to "child" it will look in "object"'s
+  children. If set to "anywhere", it will look in all the objects. If
+  object is unset, the current module's object will be used.
   Type can be: "libvlc", "playlist", "input", "decoder",
   "vout", "aout", "packetizer", "generic".
   This function is deprecated and slow and should be avoided.
diff --git a/src/misc/objects.c b/src/misc/objects.c
index ddc559b..45bd9ec 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -85,7 +85,6 @@
 static int  DumpCommand( vlc_object_t *, char const *,
                          vlc_value_t, vlc_value_t, void * );
 
-static vlc_object_t * FindParentName( vlc_object_t *, const char * );
 static vlc_object_t * FindChildName ( vlc_object_internals_t *, const char * );
 static void PrintObject( vlc_object_internals_t *, const char * );
 static void DumpStructure( vlc_object_internals_t *, unsigned, char * );
@@ -243,15 +242,10 @@ char *vlc_object_get_name(const vlc_object_t *obj)
 }
 
 /**
- ****************************************************************************
- * Destroy a vlc object (Internal)
- *
- * This function destroys an object that has been previously allocated with
- * vlc_object_create. The object's refcount must be zero and it must not be
- * attached to other objects in any way.
+ * Destroys a VLC object once it has no more references.
  *
  * This function must be called with cancellation disabled (currently).
- *****************************************************************************/
+ */
 static void vlc_object_destroy( vlc_object_t *p_this )
 {
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
@@ -455,19 +449,10 @@ vlc_object_t *vlc_object_find_name( vlc_object_t *p_this,
         return vlc_object_find_name (VLC_OBJECT(p_this->p_libvlc), psz_name,
                                      FIND_CHILD);
 
+    assert (i_mode == FIND_CHILD);
     libvlc_lock (p_this->p_libvlc);
     vlc_mutex_lock (&name_lock);
-    switch (i_mode)
-    {
-        case FIND_PARENT:
-            p_found = FindParentName (p_this, psz_name);
-            break;
-        case FIND_CHILD:
-            p_found = FindChildName (vlc_internals (p_this), psz_name);
-            break;
-        default:
-            assert (0);
-    }
+    p_found = FindChildName (vlc_internals (p_this), psz_name);
     vlc_mutex_unlock (&name_lock);
     libvlc_unlock (p_this->p_libvlc);
     return p_found;
@@ -491,10 +476,10 @@ void * vlc_object_hold( vlc_object_t *p_this )
 }
 
 #undef vlc_object_release
-/*****************************************************************************
- * Decrement an object refcount
- * And destroy the object if its refcount reach zero.
- *****************************************************************************/
+/**
+ * Drops a reference to an object (decrements the reference count).
+ * If the count reaches zero, the object is destroyed.
+ */
 void vlc_object_release( vlc_object_t *p_this )
 {
     vlc_object_internals_t *internals = vlc_internals( p_this );
@@ -557,12 +542,11 @@ void vlc_object_release( vlc_object_t *p_this )
 
 #undef vlc_object_attach
 /**
- ****************************************************************************
- * attach object to a parent object
- *****************************************************************************
- * This function sets p_this as a child of p_parent, and p_parent as a parent
- * of p_this.
- *****************************************************************************/
+ * Exposes a VLC object in the hierarchy by attaching it to another object.
+ * @note Before variables can be inherited, an object must be attached.
+ * @param p_this object to expose
+ * @param p_parent parent object in the hierarchy
+ */
 void vlc_object_attach( vlc_object_t *p_this, vlc_object_t *p_parent )
 {
     if( !p_this ) return;
@@ -761,19 +745,6 @@ void vlc_list_release( vlc_list_t *p_list )
 
 /* Following functions are local */
 
-static vlc_object_t *FindParentName (vlc_object_t *p_this, const char *name)
-{
-    for (vlc_object_t *parent = p_this->p_parent;
-         parent != NULL;
-         parent = parent->p_parent)
-    {
-        const char *objname = vlc_internals (parent)->psz_name;
-        if (objname && !strcmp (objname, name))
-            return vlc_object_hold (parent);
-    }
-    return NULL;
-}
-
 static vlc_object_t *FindChildName (vlc_object_internals_t *priv,
                                     const char *name)
 {



More information about the vlc-commits mailing list