3 void refcount_ini(Refcount *refcount, void *obj, Callback del)
8 pthread_mutex_init(&refcount->mtx, NULL);
11 void refcount_dst(Refcount *refcount)
13 pthread_mutex_destroy(&refcount->mtx);
16 void *refcount_inc(void *refcount)
18 Refcount *rc = refcount;
20 pthread_mutex_lock(&rc->mtx);
22 pthread_mutex_unlock(&rc->mtx);
26 void *refcount_grb(void *refcount)
28 return refcount_obj(refcount_inc(refcount));
31 void refcount_drp(void *refcount)
33 Refcount *rc = refcount;
35 pthread_mutex_lock(&rc->mtx);
36 unsigned short count = --rc->cnt;
37 pthread_mutex_unlock(&rc->mtx);
43 void *refcount_obj(void *refcount)
45 return ((Refcount *) refcount)->obj;