fix breakqge introduce in [16152]
[vlc.git] / test / native / gc.c
blobde198de2f4c5daaf79a89a8803ba8e1a4ecabc5d
1 #include "../pyunit.h"
2 #include <vlc/vlc.h>
4 struct mygc
6 VLC_GC_MEMBERS;
7 int i;
8 };
10 typedef struct mygc mygc;
12 static void mygc_destructor( gc_object_t *p_gc )
14 free( p_gc );
15 p_gc = NULL;
18 static PyObject *gc_test( PyObject *self, PyObject *args )
20 mygc *gc = (mygc *)malloc( sizeof( mygc ) );
22 vlc_gc_init( gc, mygc_destructor, NULL );
23 ASSERT( gc->i_gc_refcount == 0, "Refcount should be 0" );
24 vlc_gc_incref( gc );
25 ASSERT( gc->i_gc_refcount == 1, "Refcount should be 1" );
26 vlc_gc_incref( gc );
27 ASSERT( gc->i_gc_refcount == 2, "Refcount should be 2" );
28 gc->i++;
29 vlc_gc_decref( gc );
30 ASSERT( gc->i_gc_refcount == 1, "Refcount should be 1" );
31 vlc_gc_decref( gc );
33 Py_INCREF( Py_None );
34 return Py_None;
37 static PyMethodDef native_gc_test_methods[] = {
38 DEF_METHOD( gc_test, "Test GC" )
39 { NULL, NULL, 0, NULL }
42 DECLARE_MODULE( native_gc_test )