summaryrefslogtreecommitdiff
path: root/gir/glib-2.0.c
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2020-02-17 19:22:11 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2020-02-17 19:22:11 +0100
commit80799e2453f4f6213892f191a785f298be1ee715 (patch)
tree34fca8f37c1e4ec78df259dc1ff329bab5a6127b /gir/glib-2.0.c
parent82e55f5fa2f70ff3ba7a953fa3430eb922617e7a (diff)
downloadgobject-introspection-80799e2453f4f6213892f191a785f298be1ee715.tar.gz
Update glib annotations
Diffstat (limited to 'gir/glib-2.0.c')
-rw-r--r--gir/glib-2.0.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/gir/glib-2.0.c b/gir/glib-2.0.c
index 4830ee57..cb671c7a 100644
--- a/gir/glib-2.0.c
+++ b/gir/glib-2.0.c
@@ -17264,12 +17264,16 @@
/**
* g_hash_table_add:
* @hash_table: a #GHashTable
- * @key: a key to insert
+ * @key: (transfer full): a key to insert
*
* This is a convenience function for using a #GHashTable as a set. It
* is equivalent to calling g_hash_table_replace() with @key as both the
* key and the value.
*
+ * In particular, this means that if @key already exists in the hash table, then
+ * the old copy of @key in the hash table is freed and @key replaces it in the
+ * table.
+ *
* When a hash table only ever contains keys that have themselves as the
* corresponding value it is able to be stored more efficiently. See
* the discussion in the section description.
@@ -20323,6 +20327,13 @@
*
* If list elements contain dynamically-allocated memory, you should
* either use g_list_free_full() or free them manually first.
+ *
+ * It can be combined with g_steal_pointer() to ensure the list head pointer
+ * is not left dangling:
+ * |[<!-- language="C" -->
+ * GList *list_of_borrowed_things = …; /<!-- -->* (transfer container) *<!-- -->/
+ * g_list_free (g_steal_pointer (&list_of_borrowed_things));
+ * ]|
*/
@@ -20356,6 +20367,15 @@
* @free_func must not modify the list (eg, by removing the freed
* element from it).
*
+ * It can be combined with g_steal_pointer() to ensure the list head pointer
+ * is not left dangling ­— this also has the nice property that the head pointer
+ * is cleared before any of the list elements are freed, to prevent double frees
+ * from @free_func:
+ * |[<!-- language="C" -->
+ * GList *list_of_owned_things = …; /<!-- -->* (transfer full) (element-type GObject) *<!-- -->/
+ * g_list_free_full (g_steal_pointer (&list_of_owned_things), g_object_unref);
+ * ]|
+ *
* Since: 2.28
*/
@@ -28900,6 +28920,13 @@
* If list elements contain dynamically-allocated memory,
* you should either use g_slist_free_full() or free them manually
* first.
+ *
+ * It can be combined with g_steal_pointer() to ensure the list head pointer
+ * is not left dangling:
+ * |[<!-- language="C" -->
+ * GSList *list_of_borrowed_things = …; /<!-- -->* (transfer container) *<!-- -->/
+ * g_slist_free (g_steal_pointer (&list_of_borrowed_things));
+ * ]|
*/
@@ -28932,6 +28959,15 @@
* @free_func must not modify the list (eg, by removing the freed
* element from it).
*
+ * It can be combined with g_steal_pointer() to ensure the list head pointer
+ * is not left dangling ­— this also has the nice property that the head pointer
+ * is cleared before any of the list elements are freed, to prevent double frees
+ * from @free_func:
+ * |[<!-- language="C" -->
+ * GSList *list_of_owned_things = …; /<!-- -->* (transfer full) (element-type GObject) *<!-- -->/
+ * g_slist_free_full (g_steal_pointer (&list_of_owned_things), g_object_unref);
+ * ]|
+ *
* Since: 2.28
*/