References counting
Eina » Data Types

Small macro that simplify references counting. More...

## Macros

#define | EINA_REFCOUNT Eina_Refcount __refcount
| Used for declaring a reference counting member in a struct.
#define | EINA_REFCOUNT_INIT(Variable)
| Used just after allocating a object.
#define | EINA_REFCOUNT_REF(Variable)
| Used when using referring to an object one more time.
#define | EINA_REFCOUNT_UNREF(Variable)
| Used when removing a reference to an object.
#define | EINA_REFCOUNT_GET(Variable)
| Get refcounting value.

## Typedefs

typedef int | Eina_Refcount
| Inlined references counting type.

## Detailed Description

Small macro that simplify references counting.

References counting is not a difficult task, but you must handle it correctly every where, and that the issue. This set of macro do provide helper that will force to use the correct code in most case and reduce the bug likeliness. Of course this without affecting speed !

## Macro Definition Documentation

## EINA_REFCOUNT_INIT

#define EINA_REFCOUNT_INIT | ( |  | Variable | ) |

Value:
(Variable)->__refcount = 1

Used just after allocating a object.

Referenced by eeze_net_new(), eio_monitor_stringshared_add(), and ethumb_client_connect().

## EINA_REFCOUNT_REF

#define EINA_REFCOUNT_REF | ( |  | Variable | ) |

Value:
(Variable)->__refcount++

Used when using referring to an object one more time.

Referenced by eeze_net_new(), eio_monitor_stringshared_add(), emotion_object_last_position_load(), emotion_object_last_position_save(), and ethumb_client_thumb_exists().

## EINA_REFCOUNT_UNREF

#define EINA_REFCOUNT_UNREF | ( |  | Variable | ) |

Value:
if (--((Variable)->__refcount) == 0)

Used when removing a reference to an object.

The code just after will automatically be called when necessary

Referenced by eeze_net_free(), eio_monitor_del(), ethumb_client_disconnect(), and ethumb_client_thumb_exists_cancel().

## EINA_REFCOUNT_GET

#define EINA_REFCOUNT_GET | ( |  | Variable | ) |

Value:
(Variable)->__refcount

Get refcounting value.