Changeset 56a0945078146cedcd3c9e33ce86caa24de79b2f

Show
Ignore:
Timestamp:
03/19/08 00:05:06 (5 months ago)
Author:
Pierre d'Herbemont <pdherbemont@free.fr>
git-committer:
Pierre d'Herbemont <pdherbemont@free.fr> 1205881506 +0100
git-parent:

[879e3eb226c7df84db6868b25964830664f92ebb]

git-author:
Pierre d'Herbemont <pdherbemont@free.fr> 1205879003 +0100
Message:

vlc_objects.h: Export and implement vlc_object_set_destructor().

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_objects.h

    r55f3a9f r56a0945  
    8484#define OBJECT_FLAGS_NOINTERACT  0x0004 
    8585 
     86/* Types */ 
     87typedef void (*vlc_destructor_t)(struct vlc_object_t *); 
     88 
     89/* Constants */ 
     90VLC_PUBLIC_API const vlc_destructor_t kVLCDestructor; 
     91 
    8692/***************************************************************************** 
    8793 * The vlc_object_t type. Yes, it's that simple :-) 
     
    97103 *****************************************************************************/ 
    98104VLC_EXPORT( void *, __vlc_object_create, ( vlc_object_t *, int ) ); 
     105VLC_EXPORT( void, __vlc_object_set_destructor, ( vlc_object_t *, vlc_destructor_t ) ); 
    99106VLC_EXPORT( void, __vlc_object_attach, ( vlc_object_t *, vlc_object_t * ) ); 
    100107VLC_EXPORT( void, __vlc_object_detach, ( vlc_object_t * ) ); 
     
    112119    __vlc_object_create( VLC_OBJECT(a), b ) 
    113120 
     121#define vlc_object_set_destructor(a,b) \ 
     122    __vlc_object_set_destructor( VLC_OBJECT(a), b ) 
     123 
    114124#define vlc_object_detach(a) \ 
    115125    __vlc_object_detach( VLC_OBJECT(a) ) 
  • src/libvlc.h

    rb3a086f r56a0945  
    134134 
    135135    /* Objects management */ 
    136     unsigned        i_refcount; 
    137     vlc_bool_t      b_attached; 
     136    unsigned         i_refcount; 
     137    vlc_destructor_t pf_destructor; 
     138    vlc_bool_t       b_attached; 
    138139}; 
    139140 
  • src/misc/objects.c

    r55f3a9f r56a0945  
    7474 
    7575/***************************************************************************** 
     76 * Constants 
     77 *****************************************************************************/ 
     78 
     79const vlc_destructor_t kVLCDestructor = NULL; 
     80 
     81/***************************************************************************** 
    7682 * Local prototypes 
    7783 *****************************************************************************/ 
     
    194200 
    195201    p_priv->i_refcount = 1; 
     202    p_priv->pf_destructor = kVLCDestructor; 
    196203    p_new->p_parent = NULL; 
    197204    p_new->pp_children = NULL; 
     
    355362/** 
    356363 **************************************************************************** 
     364 * Set the destructor of a vlc object 
     365 * 
     366 * This function sets the destructor of the vlc object. It will be called 
     367 * when the object is destroyed when the its refcount reaches 0. 
     368 * (It is called by the internal function vlc_object_destroy()) 
     369 *****************************************************************************/ 
     370void __vlc_object_set_destructor( vlc_object_t *p_this, 
     371                                  vlc_destructor_t pf_destructor ) 
     372{ 
     373    vlc_object_internals_t *p_priv = vlc_internals(p_this ); 
     374 
     375    vlc_mutex_lock( &structure_lock ); 
     376    p_priv->pf_destructor = pf_destructor; 
     377    vlc_mutex_unlock( &structure_lock ); 
     378} 
     379 
     380/** 
     381 **************************************************************************** 
    357382 * Destroy a vlc object (Internal) 
    358383 * 
     
    400425        abort(); 
    401426    } 
     427 
     428    /* Call the custom "subclass" destructor */ 
     429    if( p_priv->pf_destructor ) 
     430        p_priv->pf_destructor( p_this ); 
     431 
    402432 
    403433    /* Destroy the associated variables, starting from the end so that