]> git.sesse.net Git - vlc/blob - test/native/gc.c
Use var_InheritString for --decklink-video-connection.
[vlc] / test / native / gc.c
1 #include "../pyunit.h"
2 #ifdef HAVE_CONFIG_H
3 # include "config.h"
4 #endif
5
6 #include <vlc/vlc.h>
7
8 struct mygc
9 {
10     VLC_GC_MEMBERS;
11     int i;
12 };
13
14 typedef struct mygc mygc;
15
16 static void mygc_destructor( gc_object_t *p_gc )
17 {
18     free( p_gc );
19     p_gc = NULL;
20 };
21
22 static PyObject *gc_test( PyObject *self, PyObject *args )
23 {
24      mygc *gc = (mygc *)malloc( sizeof( mygc ) );
25
26      vlc_gc_init( gc, mygc_destructor, NULL );
27      ASSERT( gc->i_gc_refcount == 0, "Refcount should be 0" );
28      vlc_gc_incref( gc );
29      ASSERT( gc->i_gc_refcount == 1, "Refcount should be 1" );
30      vlc_gc_incref( gc );
31      ASSERT( gc->i_gc_refcount == 2, "Refcount should be 2" );
32      gc->i++;
33      vlc_gc_decref( gc );
34      ASSERT( gc->i_gc_refcount == 1, "Refcount should be 1" );
35      vlc_gc_decref( gc );
36
37      Py_INCREF( Py_None );
38      return Py_None;
39 };
40
41 static PyMethodDef native_gc_test_methods[] = {
42    DEF_METHOD( gc_test, "Test GC" )
43    { NULL, NULL, 0, NULL }
44 };
45
46 asserts = 0;
47
48 DECLARE_MODULE( native_gc_test )