refcount.h File Reference
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <stddef.h>`
`#include <pthread.h>`
Include dependency graph for refcount.h:

Go to the source code of this file.

## Data Structures

struct | refcount_

## Macros

#define | ref_upcast(DAT)
#define | ref_barrier(CODE)

## Functions

static void | ref_init_functions (void *(*mallocf)(size_t), void *(*callocf)(size_t, size_t), void *(*reallocf)(void *, size_t), void(*freef)(void *))
static unsigned int | ref_inc (void *buf)
static unsigned int | ref_dec (void *buf)
static void * | ref_malloc (size_t size)
static void | ref_free (void *buf)

## Variables

static void(* | REF_free )(void *) = free
static void *(* | REF_realloc )(void *, size_t) = realloc
static void *(* | REF_malloc )(size_t) = malloc

## Macro Definition Documentation

## ref_barrier

#define ref_barrier | ( |  | CODE | ) |

Value:
pthread_mutex_lock(&refc->mux); \
CODE \
pthread_mutex_unlock(&refc->mux)

Definition at line 21 of file refcount.h.

## ref_upcast

#define ref_upcast | ( |  | DAT | ) |

Value:
(struct refcount_ *)((char *)(DAT - offsetof(struct refcount_, data)))
refcount_
Definition refcount.h:12

Definition at line 18 of file refcount.h.

## Function Documentation

## ref_dec()

unsigned int ref_dec | ( | void * | buf | ) |

static

Definition at line 51 of file refcount.h.

## ref_free()

void ref_free | ( | void * | buf | ) |

static

Definition at line 78 of file refcount.h.

## ref_inc()

unsigned int ref_inc | ( | void * | buf | ) |

static

Definition at line 40 of file refcount.h.

## ref_init_functions()

void ref_init_functions | ( | void *(* | mallocf )(size_t),
|  | void *(* | callocf )(size_t, size_t),
|  | void *(* | reallocf )(void *, size_t),
|  | void(* | freef )(void *) )

inline static

Definition at line 28 of file refcount.h.

## ref_malloc()

void * ref_malloc | ( | size_t | size | ) |

inline static

Definition at line 62 of file refcount.h.

## Variable Documentation

## REF_free

void(* REF_free) (void *) | ( | void * |  | ) | = free

static

Definition at line 8 of file refcount.h.

## REF_malloc

void *(* REF_malloc) (size_t) | ( | size_t |  | ) | = malloc

static

Definition at line 10 of file refcount.h.

## REF_realloc

void *(* REF_realloc) (void *, size_t) | ( | void * | ,
|  | size_t | ) = realloc

static

Definition at line 9 of file refcount.h.