X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Flibvlc.c;h=7340e365f8634e003cca0401c586559986fbd691;hb=16c8c42c018364be49a7a913db7fd4adce1180d9;hp=f68221ff121f39639baedfc0214c4333fb5352ef;hpb=2265c8f1cc3aa9d661b7662199f38e46faa9dad2;p=vlc 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 *****************************************************************************/