On Thu, 2015-02-19 at 10:22 -0500, Colin Walters wrote:
On Thu, Feb 19, 2015, at 05:32 AM, Philip Withnall wrote:If there is no convention, I suggest it makes more sense to have the caller only ever call g_array_unref(), g_ptr_array_unref(), g_hash_table_unref(), and never explicitly free the elements. For (transfer full), the callee should be responsible for setting the clear/free function for elements. For (transfer container), the callee should be responsible for *not* setting such a function (or for adding the elements to a newly allocated container with no free function set, or similar).Introspection dates to before pervasive use of container free functions. Basically yes, people should be using (transfer container) as much as possible today. If (transfer full) is specified, it definitely means the caller is responsible for freeing each element.
From some brief grepping for GHashTable, at least the following modules get it wrong wrt what you’re saying: • GIO (GMenuModel.get_item_attributes) • libsecret (for example, SecretItem.get_attributes) • libsoup (ContentSniffer.sniff) They have (transfer full) but then expect g_hash_table_unref() to be used. It seems there has been confusion over this, and annotations are going to have to be fixed in multiple modules. Colin, if you’re sure this is the best way to define the semantics, we should mail DDL or blog about it to get people to fix their annotations. And update the annotations wiki page. Philip
Attachment:
signature.asc
Description: This is a digitally signed message part