9 static void * (* REF_realloc)(
void *, size_t) = realloc;
10 static void * (* REF_malloc)(size_t) = malloc;
18 #define ref_upcast(DAT) \
19 (struct refcount_ *)((char *)(DAT - offsetof(struct refcount_, data)))
21 #define ref_barrier(CODE) \
22 pthread_mutex_lock(&refc->mux); \
24 pthread_mutex_unlock(&refc->mux)
29 void * (*callocf)(
size_t,
size_t),
30 void *(*reallocf)(
void *,
size_t),
31 void (*freef)(
void *))
65 pthread_mutexattr_t attr;
70 pthread_mutexattr_init(&attr);
71 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
72 pthread_mutex_init(&refc->
mux, &attr);
83 if (--refc->
count == 0)
85 pthread_mutex_unlock(&refc->mux);
86 pthread_mutex_destroy(&refc->mux);
87 return REF_free(refc);
static void(* REF_free)(void *)
static void ref_init_functions(void *(*mallocf)(size_t), void *(*callocf)(size_t, size_t), void *(*reallocf)(void *, size_t), void(*freef)(void *))
static void * ref_malloc(size_t size)
#define ref_barrier(CODE)
static void *(* REF_realloc)(void *, size_t)
static unsigned int ref_inc(void *buf)
static void ref_free(void *buf)
static void *(* REF_malloc)(size_t)
static unsigned int ref_dec(void *buf)