From 38276a4632c98f6e98186adbb1a1538168e1a697 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sun, 4 May 2008 19:16:00 +0300 Subject: [PATCH] Remove VLC_OBJECT_GLOBAL --- include/vlc_objects.h | 2 +- modules/misc/lua/objects.c | 3 +-- src/misc/objects.c | 9 ++++++--- src/misc/threads.c | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/vlc_objects.h b/include/vlc_objects.h index 828510442a..da73ea8e18 100644 --- a/include/vlc_objects.h +++ b/include/vlc_objects.h @@ -36,7 +36,7 @@ */ /* Object types */ -#define VLC_OBJECT_GLOBAL (-1) + #define VLC_OBJECT_LIBVLC (-2) #define VLC_OBJECT_MODULE (-3) #define VLC_OBJECT_INTF (-4) diff --git a/modules/misc/lua/objects.c b/modules/misc/lua/objects.c index 9feff684d9..deb99189f9 100644 --- a/modules/misc/lua/objects.c +++ b/modules/misc/lua/objects.c @@ -107,8 +107,7 @@ static int vlc_object_type_from_string( const char *psz_name ) int i_type; const char *psz_name; } pp_objects[] = - { { VLC_OBJECT_GLOBAL, "global" }, - { VLC_OBJECT_LIBVLC, "libvlc" }, + { { VLC_OBJECT_LIBVLC, "libvlc" }, { VLC_OBJECT_MODULE, "module" }, { VLC_OBJECT_INTF, "intf" }, { VLC_OBJECT_PLAYLIST, "playlist" }, diff --git a/src/misc/objects.c b/src/misc/objects.c index 33c8b32de1..2395698e40 100644 --- a/src/misc/objects.c +++ b/src/misc/objects.c @@ -143,9 +143,9 @@ void *vlc_custom_create( vlc_object_t *p_this, size_t i_size, } libvlc_global_data_t *p_libvlc_global; - if( i_type == VLC_OBJECT_GLOBAL ) + if( p_this == NULL ) { - /* If i_type is global, then p_new is actually p_libvlc_global */ + /* Only the global root object is created out of the blue */ p_libvlc_global = (libvlc_global_data_t *)p_new; p_new->p_libvlc = NULL; @@ -379,10 +379,12 @@ static void vlc_object_destroy( vlc_object_t *p_this ) free( p_this->psz_header ); - if( p_this->i_object_type == VLC_OBJECT_GLOBAL ) + if( p_this->p_libvlc == NULL ) { libvlc_global_data_t *p_global = (libvlc_global_data_t *)p_this; +#ifndef NDEBUG + assert( p_global == vlc_global() ); /* Test for leaks */ if( p_global->i_objects > 0 ) { @@ -408,6 +410,7 @@ static void vlc_object_destroy( vlc_object_t *p_this ) /* Strongly abort, cause we want these to be fixed */ abort(); } +#endif /* We are the global object ... no need to lock. */ free( p_global->pp_objects ); diff --git a/src/misc/threads.c b/src/misc/threads.c index 48d3498302..8b0b3b9e56 100644 --- a/src/misc/threads.c +++ b/src/misc/threads.c @@ -143,7 +143,7 @@ int vlc_threads_init( void ) if( i_initializations == 0 ) { p_root = vlc_custom_create( NULL, sizeof( *p_root ), - VLC_OBJECT_GLOBAL, "global" ); + VLC_OBJECT_GENERIC, "root" ); if( p_root == NULL ) { i_ret = VLC_ENOMEM; -- 2.39.5