mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
Merge branch 'ebassi/refcount-init-macros' into 'main'
Add init macros for refcounting types See merge request GNOME/glib!3366
This commit is contained in:
commit
fd493cacf2
@ -3689,12 +3689,14 @@ g_ref_count_init
|
||||
g_ref_count_inc
|
||||
g_ref_count_dec
|
||||
g_ref_count_compare
|
||||
G_REF_COUNT_INIT
|
||||
<SUBSECTION>
|
||||
gatomicrefcount
|
||||
g_atomic_ref_count_init
|
||||
g_atomic_ref_count_inc
|
||||
g_atomic_ref_count_dec
|
||||
g_atomic_ref_count_compare
|
||||
G_ATOMIC_REF_COUNT_INIT
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
|
@ -50,6 +50,60 @@ GLIB_AVAILABLE_IN_2_58
|
||||
gboolean g_atomic_ref_count_compare (gatomicrefcount *arc,
|
||||
gint val);
|
||||
|
||||
/**
|
||||
* G_REF_COUNT_INIT:
|
||||
*
|
||||
* Evaluates to the initial reference count for `grefcount`.
|
||||
*
|
||||
* This macro is useful for initializing `grefcount` fields inside
|
||||
* structures, for instance:
|
||||
*
|
||||
* |[<!-- language="C" -->
|
||||
* typedef struct {
|
||||
* grefcount ref_count;
|
||||
* char *name;
|
||||
* char *address;
|
||||
* } Person;
|
||||
*
|
||||
* static const Person default_person = {
|
||||
* .ref_count = G_REF_COUNT_INIT,
|
||||
* .name = "Default name",
|
||||
* .address = "Default address",
|
||||
* };
|
||||
* ]|
|
||||
*
|
||||
* Since: 2.78
|
||||
*/
|
||||
#define G_REF_COUNT_INIT -1 \
|
||||
GLIB_AVAILABLE_MACRO_IN_2_78
|
||||
|
||||
/**
|
||||
* G_ATOMIC_REF_COUNT_INIT:
|
||||
*
|
||||
* Evaluates to the initial reference count for `gatomicrefcount`.
|
||||
*
|
||||
* This macro is useful for initializing `gatomicrefcount` fields inside
|
||||
* structures, for instance:
|
||||
*
|
||||
* |[<!-- language="C" -->
|
||||
* typedef struct {
|
||||
* gatomicrefcount ref_count;
|
||||
* char *name;
|
||||
* char *address;
|
||||
* } Person;
|
||||
*
|
||||
* static const Person default_person = {
|
||||
* .ref_count = G_ATOMIC_REF_COUNT_INIT,
|
||||
* .name = "Default name",
|
||||
* .address = "Default address",
|
||||
* };
|
||||
* ]|
|
||||
*
|
||||
* Since: 2.78
|
||||
*/
|
||||
#define G_ATOMIC_REF_COUNT_INIT 1 \
|
||||
GLIB_AVAILABLE_MACRO_IN_2_78
|
||||
|
||||
/* On GCC we can use __extension__ to inline the API without using
|
||||
* ancillary functions; we only do this when disabling checks, as
|
||||
* it disables warnings when saturating the reference counters
|
||||
|
Loading…
Reference in New Issue
Block a user