CpgRefCounted

CpgRefCounted — A lightweight reference counted object

Synopsis


#include <cpg-network/cpg-ref-counted.h>

                    CpgRefCounted;
void                cpg_ref_counted_init                (gpointer ref_counted,
                                                         GDestroyNotify destroy_func);
gpointer            cpg_ref_counted_ref                 (gpointer ref_counted);
void                cpg_ref_counted_unref               (gpointer ref_counted);

Description

CpgRefCounted is a very lightweight implementation of a reference counted object, similar to GObject but without all the additional functionality.

Details

CpgRefCounted

typedef struct _CpgRefCounted CpgRefCounted;


cpg_ref_counted_init ()

void                cpg_ref_counted_init                (gpointer ref_counted,
                                                         GDestroyNotify destroy_func);

Use this after a new ref counted object has been constructed. This sets the callback to be used when the ref count decreases to 0. The function sets the initial ref count to 1

ref_counted :

a CpgRefCounted

destroy_func :

callback to destroy the ref counted object

cpg_ref_counted_ref ()

gpointer            cpg_ref_counted_ref                 (gpointer ref_counted);

Increase the ref count on ref_counted.

ref_counted :

a CpgRefCounted

Returns :

ref_counted

cpg_ref_counted_unref ()

void                cpg_ref_counted_unref               (gpointer ref_counted);

Decrease the ref count on ref_counted.

ref_counted :

a CpgRefCounted