Reference counted data allocations
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 and juggling stack/heap reference counting
- implementing copy/free semantics with additional costs
- breaking ABI
This mechanism is similar to Rust's refcounted type container
Rc<T>, 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.
Issues: #561 (closed)