Use cleanup list to release allocated arguments.
Submitted by C. Scott Ananian
Link to original bug (#584047)
Description
Initially discussed in the comments to bug 582228.
To properly support TRANSFER_CONTAINER and bare C arrays-of-(objects), we should refactor the release code to implement a post-invocation cleanup list. Cleanups are something like:
struct _Cleanup {
enum { CLEANUP_G_FREE, CLEANUP_G_OBJECT_UNREF, CLEANUP_GI_TYPE, ... } type;
gpointer data;
}
The CLEANUP_GI_TYPE argument uses the existing GI type-driven release method, since that is necessary in any case to release TRANSFER_EVERYTHING out-parameters.
When marshaling container types from JavaScript to C, we can add cleanups for the contained objects (unless TRANSFER_CONTAINER or TRANSFER_NONE) as we add them to the container and then add a clean up for the container (unless TRANSFER_NONE).
Blocking
Edited by Philip Chimento