Commit 915f6a59 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

libvlccore: Make sure vlc_gc_* function correctly assert() on common errors, and de-inline them.

parent 9c750dec
......@@ -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 )
......
......@@ -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
*****************************************************************************/
......
......@@ -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
......
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