From 915f6a59a6b74d884a9ece2cd0d07f2a952cd834 Mon Sep 17 00:00:00 2001 From: Pierre d'Herbemont Date: Tue, 8 Jul 2008 21:32:49 +0200 Subject: [PATCH] libvlccore: Make sure vlc_gc_* function correctly assert() on common errors, and de-inline them. --- include/vlc_common.h | 30 ++++-------------------------- src/libvlc.c | 35 +++++++++++++++++++++++++++++++++++ src/libvlccore.sym | 3 +++ 3 files changed, 42 insertions(+), 26 deletions(-) diff --git a/include/vlc_common.h b/include/vlc_common.h index 451a008926..cf504c6263 100644 --- a/include/vlc_common.h +++ b/include/vlc_common.h @@ -550,32 +550,10 @@ struct gc_object_t VLC_GC_MEMBERS }; -static inline void __vlc_gc_incref( gc_object_t * p_gc ) -{ - p_gc->i_gc_refcount ++; -}; - -static inline void __vlc_gc_decref( gc_object_t *p_gc ) -{ - if( !p_gc ) return; - - p_gc->i_gc_refcount -- ; - - if( p_gc->i_gc_refcount == 0 ) - { - p_gc->pf_destructor( p_gc ); - /* Do not use the p_gc pointer from now on ! */ - } -} - -static inline void -__vlc_gc_init( gc_object_t * p_gc, void (*pf_destructor)( gc_object_t * ), - void * arg) -{ - p_gc->i_gc_refcount = 1; - p_gc->pf_destructor = pf_destructor; - p_gc->p_destructor_arg = arg; -} +VLC_EXPORT(void, __vlc_gc_incref, ( gc_object_t * p_gc )); +VLC_EXPORT(void, __vlc_gc_decref, ( gc_object_t * p_gc )); +VLC_EXPORT(void, __vlc_gc_init, ( gc_object_t * p_gc, + void (*pf_destructor)( gc_object_t * ), void * arg)); #define vlc_gc_incref( a ) __vlc_gc_incref( (gc_object_t *)a ) #define vlc_gc_decref( a ) __vlc_gc_decref( (gc_object_t *)a ) diff --git a/src/libvlc.c b/src/libvlc.c index f68221ff12..7340e365f8 100644 --- a/src/libvlc.c +++ b/src/libvlc.c @@ -105,6 +105,41 @@ static unsigned i_instances = 0; static bool b_daemon = false; +/***************************************************************************** + * vlc_gc_*. + *****************************************************************************/ +void __vlc_gc_incref( gc_object_t * p_gc ) +{ + assert( p_gc->i_gc_refcount > 0 ); + + /* FIXME: atomic version needed! */ + p_gc->i_gc_refcount ++; +} + +void __vlc_gc_decref( gc_object_t *p_gc ) +{ + assert( p_gc ); + assert( p_gc->i_gc_refcount > 0 ); + + /* FIXME: atomic version needed! */ + p_gc->i_gc_refcount -- ; + + if( p_gc->i_gc_refcount == 0 ) + { + p_gc->pf_destructor( p_gc ); + /* Do not use the p_gc pointer from now on ! */ + } +} + +void +__vlc_gc_init( gc_object_t * p_gc, void (*pf_destructor)( gc_object_t * ), + void * arg) +{ + p_gc->i_gc_refcount = 1; + p_gc->pf_destructor = pf_destructor; + p_gc->p_destructor_arg = arg; +} + /***************************************************************************** * Local prototypes *****************************************************************************/ diff --git a/src/libvlccore.sym b/src/libvlccore.sym index d74bd7a386..9ea497652c 100644 --- a/src/libvlccore.sym +++ b/src/libvlccore.sym @@ -414,6 +414,9 @@ __vlc_execve vlc_fastmem_register vlc_freeaddrinfo vlc_gai_strerror +__vlc_gc_incref +__vlc_gc_init +__vlc_gc_decref vlc_getaddrinfo vlc_getnameinfo vlc_gettext -- 2.39.2