Commit d21779b9 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Remove some global object-specific hacks

parent e8d99a6b
......@@ -95,7 +95,6 @@ static void vlc_object_yield_locked( vlc_object_t *p_this );
* Local structure lock
*****************************************************************************/
static vlc_mutex_t structure_lock;
static vlc_object_internals_t global_internals;
void *vlc_custom_create( vlc_object_t *p_this, size_t i_size,
int i_type, const char *psz_type )
......@@ -103,19 +102,15 @@ void *vlc_custom_create( vlc_object_t *p_this, size_t i_size,
vlc_object_t *p_new;
vlc_object_internals_t *p_priv;
p_priv = calloc( 1, sizeof( *p_priv ) + i_size );
if( p_priv == NULL )
return NULL;
if( i_type == VLC_OBJECT_GLOBAL )
{
p_new = p_this;
p_priv = &global_internals;
memset( p_priv, 0, sizeof( *p_priv ) );
}
else
{
assert (i_size >= sizeof (vlc_object_t));
p_priv = calloc( 1, sizeof( *p_priv ) + i_size );
if( p_priv == NULL )
return NULL;
p_new = (vlc_object_t *)(p_priv + 1);
}
......@@ -133,18 +128,13 @@ void *vlc_custom_create( vlc_object_t *p_this, size_t i_size,
p_new->psz_header = NULL;
if( p_this->i_flags & OBJECT_FLAGS_NODBG )
p_new->i_flags |= OBJECT_FLAGS_NODBG;
if( p_this->i_flags & OBJECT_FLAGS_QUIET )
p_new->i_flags |= OBJECT_FLAGS_QUIET;
if( p_this->i_flags & OBJECT_FLAGS_NOINTERACT )
p_new->i_flags |= OBJECT_FLAGS_NOINTERACT;
p_new->i_flags |= p_this->i_flags
& (OBJECT_FLAGS_NODBG|OBJECT_FLAGS_QUIET|OBJECT_FLAGS_NOINTERACT);
p_priv->p_vars = calloc( sizeof( variable_t ), 16 );
if( !p_priv->p_vars )
{
if( i_type != VLC_OBJECT_GLOBAL )
free( p_priv );
return NULL;
}
......@@ -162,6 +152,7 @@ void *vlc_custom_create( vlc_object_t *p_this, size_t i_size,
p_libvlc_global->pp_objects = malloc( sizeof(vlc_object_t *) );
p_libvlc_global->pp_objects[0] = p_new;
p_priv->b_attached = VLC_TRUE;
vlc_mutex_init( p_new, &structure_lock );
}
else
{
......@@ -205,11 +196,6 @@ void *vlc_custom_create( vlc_object_t *p_this, size_t i_size,
vlc_spin_init( &p_priv->spin );
p_priv->pipes[0] = p_priv->pipes[1] = -1;
if( i_type == VLC_OBJECT_GLOBAL )
{
vlc_mutex_init( p_new, &structure_lock );
}
if( i_type == VLC_OBJECT_LIBVLC )
{
var_Create( p_new, "list", VLC_VAR_STRING | VLC_VAR_ISCOMMAND );
......@@ -434,8 +420,6 @@ static void vlc_object_destroy( vlc_object_t *p_this )
if( p_priv->pipes[0] != -1 )
close( p_priv->pipes[0] );
/* global is not dynamically allocated by vlc_object_create */
if( p_this->i_object_type != VLC_OBJECT_GLOBAL )
free( p_priv );
}
......
......@@ -187,8 +187,8 @@ int __vlc_threads_init( vlc_object_t *p_this )
#elif defined( LIBVLC_USE_PTHREAD )
#endif
p_root = vlc_custom_create( p_libvlc_global, 0, VLC_OBJECT_GLOBAL,
"global" );
p_root = vlc_custom_create( VLC_OBJECT(p_libvlc_global), 0,
VLC_OBJECT_GLOBAL, "global" );
if( p_root == NULL )
i_ret = VLC_ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment