6 static void * (* REF_realloc)(
void *, size_t) = realloc;
7 static void * (* REF_malloc)(size_t) = malloc;
15 #define ref_upcast(DAT) \ 16 (struct refcount_ *)((char *)(DAT - offsetof(struct refcount_, data))) 18 #define ref_barrier(CODE) \ 19 pthread_mutex_lock(&refc->mux); \ 21 pthread_mutex_unlock(&refc->mux) 26 void * (*callocf)(
size_t,
size_t),
27 void *(*reallocf)(
void *,
size_t),
28 void (* freef)(
void *))
61 pthread_mutexattr_t attr;
66 pthread_mutexattr_init(&attr);
67 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
68 pthread_mutex_init(&refc->
mux, &attr);
79 if (--refc->
count == 0)
81 pthread_mutex_unlock(&refc->mux);
82 return REF_free(refc);
static void *(* REF_malloc)(size_t)
static unsigned int ref_inc(void *buf)
static void *(* REF_realloc)(void *, size_t)
static void(* REF_free)(void *)
#define ref_barrier(CODE)
static void * ref_malloc(size_t size)
static void ref_free(void *buf)
static unsigned int ref_dec(void *buf)
static void ref_init_functions(void *(*mallocf)(size_t), void *(*callocf)(size_t, size_t), void *(*reallocf)(void *, size_t), void(*freef)(void *))