Changeset e083d4a76e9f4e5860cc7454ab226da133c30c71

Show
Ignore:
Timestamp:
21/09/08 15:59:23 (2 months ago)
Author:
Rémi Denis-Courmont <rdenis@simphalempin.com>
git-committer:
Rémi Denis-Courmont <rdenis@simphalempin.com> 1222005563 +0300
git-parent:

[8fce3d90cf2a6fcd10eab690ded15e351bb9a6f5]

git-author:
Rémi Denis-Courmont <rdenis@simphalempin.com> 1222002684 +0300
Message:

Module really does not need to be an object

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/libvlc.c

    racbad93 re083d4a  
    492492    } 
    493493 
    494     msg_Dbg( p_libvlc, "module bank initialized, found %i modules", 
    495              vlc_internals( p_module_bank )->i_children ); 
     494    size_t module_count; 
     495    module_t **list = module_list_get( &module_count ); 
     496    module_list_free( list ); 
     497    msg_Dbg( p_libvlc, "module bank initialized (%u modules)", module_count ); 
    496498 
    497499    /* Check for help on modules */ 
  • src/modules/modules.c

    racbad93 re083d4a  
    125125    if( p_module_bank == NULL ) 
    126126    { 
    127         p_bank = vlc_custom_create( p_this, sizeof(module_bank_t), 
    128                                     VLC_OBJECT_GENERIC, "module bank"); 
     127        p_bank = calloc (1, sizeof(*p_bank)); 
    129128        p_bank->i_usage = 1; 
    130129        p_bank->i_cache = p_bank->i_loaded_cache = 0; 
     
    161160void __module_EndBank( vlc_object_t *p_this ) 
    162161{ 
    163     module_t * p_next = NULL
     162    module_bank_t *p_bank
    164163 
    165164    vlc_mutex_t *lock = var_AcquireMutex( "libvlc" ); 
    166     if( !p_module_bank ) 
     165    p_bank = p_module_bank; 
     166    assert (p_bank != NULL); 
     167    if( --p_bank->i_usage > 0 ) 
    167168    { 
    168169        vlc_mutex_unlock( lock ); 
    169170        return; 
    170171    } 
    171     if( --p_module_bank->i_usage ) 
    172     { 
    173         vlc_mutex_unlock( lock ); 
    174         return; 
    175     } 
     172    /*FIXME: For thread safety, we need to: 
     173    p_module_bank = NULL; - immediately, but that will crash the cache */ 
    176174    vlc_mutex_unlock( lock ); 
    177175 
     
    180178 
    181179#ifdef HAVE_DYNAMIC_PLUGINS 
    182 # define p_bank p_module_bank 
    183180    if( p_bank->b_cache ) CacheSave( p_this ); 
    184181    while( p_bank->i_loaded_cache-- ) 
     
    210207        p_bank->pp_cache = NULL; 
    211208    } 
    212 # undef p_bank 
    213 #endif 
    214  
    215     while( vlc_internals( p_module_bank )->i_children ) 
    216     { 
    217         p_next = (module_t *)vlc_internals( p_module_bank )->pp_children[0]; 
    218         DeleteModule( p_next, true ); 
    219     } 
    220  
    221     vlc_object_release( p_module_bank ); 
    222     p_module_bank = NULL; 
     209#endif 
     210 
     211    while( p_bank->head != NULL ) 
     212        DeleteModule( p_bank->head, true ); 
     213 
     214    p_module_bank = NULL; /* FIXME: do this inside the lock */ 
     215    free( p_bank ); 
    223216} 
    224217 
     
    14141407    assert( p_module ); 
    14151408 
     1409    /* Unlist the module (if it is in the list) */ 
     1410    module_t **pp_self = &p_module_bank->head; 
     1411    while (*pp_self != NULL && *pp_self != p_module) 
     1412        pp_self = &((*pp_self)->next); 
     1413    if (*pp_self) 
     1414        *pp_self = p_module->next; 
     1415 
    14161416    /* We free the structures that we strdup()ed in Allocate*Module(). */ 
    14171417#ifdef HAVE_DYNAMIC_PLUGINS 
  • src/modules/modules.h

    r2ba61de re083d4a  
    4040struct module_bank_t 
    4141{ 
    42     VLC_COMMON_MEMBERS 
    43  
    44     int              i_usage; 
     42    unsigned         i_usage; 
    4543 
    4644    bool             b_builtins;