|
TARFS 0.1.5
Read-only TAR filesystem for ESP32
|
#include <stdint.h>#include <stdatomic.h>#include <stdlib.h>#include <stdbool.h>#include "refc.h"Go to the source code of this file.
Functions | |
| refc_type_t | addrefn (refc_t *ref, refc_type_t n) |
| Increase reference counter by specified value. | |
| refc_type_t | unrefxn (refc_t *r, void *object, refc_type_t n, void(*dtor)(void *)) |
| Release references and optionally destroy object. | |
| refc_type_t addrefn | ( | refc_t * | ref, |
| refc_type_t | n ) |
Increase reference counter by specified value.
(see refc.h for full comments)
This function attempts to increase reference counter by n (user defined integer type variable or integer literal, e.g. addrefn(&ref, 10)).
This function attempts to increase reference counter by /n/.
| ref | : pointer to reference counter. |
| n | : number of references to add. |
| refc_type_t unrefxn | ( | refc_t * | r, |
| void * | object, | ||
| refc_type_t | n, | ||
| void(* | dtor )(void *) ) |
Release references and optionally destroy object.
(see refc.h for full comments)
Decrease reference counter by /n/. When reference counter reaches zero, destructor function /dtor/ is called: in case of n > 0, object is unreferenced one by one so the destructor is called exactly once, even if n is larger than current ref counter value
Decrease reference counter by /n/. When reference counter reaches zero, destructor function /dtor/ is called.
| r | : pointer to reference counter. |
| object | : object controlled by the reference counter. |
| n | : number of references to release. If n is zero, function performs a liveness check. If /n/ is greater than current reference count, reference counter is decremented until it reaches zero. Destructor function is called exactly once. |
| dtor | : destructor function. standart C function free() can be used here If dtor is NULL, object is not destroyed even when reference counter reaches zero, possibly creating a memory leak. |
Value of 0 is returned when some fatal eeror is occured: attempt to unref the object which is being deleted; pointer to the r is NULL