Add refcounted data

It is useful to provide a "reference counted allocation" API that can
add reference counting semantics to any memory allocation. This allows
turning data structures that usually are placed on the stack into memory
that can be placed on the heap without:

 - adding a public reference count field
 - implementing copy/free semantics

This mechanism is similar to Rust's Rc<Box<T>> combination of traits,
and uses a Valgrind-friendly overallocation mechanism to store the
reference count into a private data segment, like we do with GObject's
private instance data.
This commit is contained in:
Emmanuele Bassi
2018-06-10 12:20:34 +01:00
parent 884c4f4eb6
commit c5d2417d07
10 changed files with 555 additions and 0 deletions

View File

@@ -120,6 +120,7 @@
<xi:include href="gvariant-varargs.xml"/>
<xi:include href="gvariant-text.xml"/>
<xi:include href="xml/refcount.xml"/>
<xi:include href="xml/rcbox.xml"/>
</chapter>
<chapter id="deprecated">

View File

@@ -3466,3 +3466,15 @@ g_atomic_ref_count_inc
g_atomic_ref_count_dec
g_atomic_ref_count_compare
</SECTION>
<SECTION>
<FILE>rcbox</FILE>
g_rc_box_alloc
g_rc_box_alloc0
g_rc_box_new
g_rc_box_new0
g_rc_box_dup
g_rc_box_acquire
g_rc_box_release
g_rc_box_release_full
</SECTION>