Skip to contentSkip to conversation

qom/object: Comment to use g_slist_free on object_class_get_list result

PATCH In review Philippe Mathieu-Daudé 3 participants 6 messages Feb 27, 2020 – Feb 28, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qom/object: Comment to use g_slist_free on object_class_get_list result

Document the list returned by object_class_get_list() must be released with g_slist_free() to avoid memory leaks.

---
 include/qom/object.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/qom/object.h +6 -0
index 29546496c1..5517b56508 100644
@@ -984,6 +984,9 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
  * @include_abstract: Whether to include abstract classes.
  *
  * Returns: A singly-linked list of the classes in reverse hashtable order.
+ *
+ * The returned list must be released with g_slist_free()
+ * when no longer required.
  */
 GSList *object_class_get_list(const char *implements_type,
                               bool include_abstract);
@@ -995,6 +998,9 @@ GSList *object_class_get_list(const char *implements_type,
  *
  * Returns: A singly-linked list of the classes in alphabetical
  * case-insensitive order.
+ *
+ * The returned list must be released with g_slist_free()
+ * when no longer required.
  */
 GSList *object_class_get_list_sorted(const char *implements_type,
                               bool include_abstract);
Signature · 1 line
2.21.1
#1 lore raw
Quoted 13 lines · Philippe Mathieu-Daudé

Document the list returned by object_class_get_list() must be released with g_slist_free() to avoid memory leaks.

---
 include/qom/object.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/qom/object.h +0 -0
index 29546496c1..5517b56508 100644

include/qom/object.h void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), · line 989

Quoted 6 lines
include/qom/object.h +3 -0
@@ -984,6 +984,9 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
  * @include_abstract: Whether to include abstract classes.
  *
  * Returns: A singly-linked list of the classes in reverse hashtable order.
+ *
+ * The returned list must be released with g_slist_free()
+ * when no longer required.

I'd suggest

"The returned list, but not its elements, must be released with
g_slist_free() or g_autoptr when no longer required"

Quoted 17 lines
include/qom/object.h +3 -0
  */
 GSList *object_class_get_list(const char *implements_type,
                               bool include_abstract);
@@ -995,6 +998,9 @@ GSList *object_class_get_list(const char *implements_type,
  *
  * Returns: A singly-linked list of the classes in alphabetical
  * case-insensitive order.
+ *
+ * The returned list must be released with g_slist_free()
+ * when no longer required.
  */
 GSList *object_class_get_list_sorted(const char *implements_type,
                               bool include_abstract);
Signature · 1 line
2.21.1

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#2 lore raw

Hi

Quoted 24 lines · Daniel P. Berrangé
Quoted 13 lines · Philippe Mathieu-Daudé

Document the list returned by object_class_get_list() must be released with g_slist_free() to avoid memory leaks.

---
 include/qom/object.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/qom/object.h +0 -0
index 29546496c1..5517b56508 100644

include/qom/object.h void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), · line 989

Quoted 6 lines
include/qom/object.h +3 -0
@@ -984,6 +984,9 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
  * @include_abstract: Whether to include abstract classes.
  *
  * Returns: A singly-linked list of the classes in reverse hashtable order.
+ *
+ * The returned list must be released with g_slist_free()
+ * when no longer required.

I'd suggest

Quoted 2 lines

"The returned list, but not its elements, must be released with
g_slist_free() or g_autoptr when no longer required"

As gobject-introspection annotations: "Returns: (transfer container) (element-type ObjectClass): A list of #ObjectClass"

Quoted 27 lines
Quoted 15 lines
include/qom/object.h +3 -1
  */
 GSList *object_class_get_list(const char *implements_type,
                               bool include_abstract);
@@ -995,6 +998,9 @@ GSList *object_class_get_list(const char *implements_type,
  *
  * Returns: A singly-linked list of the classes in alphabetical
  * case-insensitive order.
+ *
+ * The returned list must be released with g_slist_free()
+ * when no longer required.
  */
 GSList *object_class_get_list_sorted(const char *implements_type,
                               bool include_abstract);
--
Quoted 3 lines

2.21.1

Regards,
Daniel
--

|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Signature · 1 line
Marc-André Lureau
#3 lore raw
Quoted 27 lines · Marc-André Lureau

Hi

Quoted 24 lines · Daniel P. Berrangé
Quoted 13 lines · Philippe Mathieu-Daudé

Document the list returned by object_class_get_list() must be released with g_slist_free() to avoid memory leaks.

---
  include/qom/object.h | 6 ++++++
  1 file changed, 6 insertions(+)
include/qom/object.h +0 -0
index 29546496c1..5517b56508 100644

include/qom/object.h void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), · line 989

Quoted 6 lines
include/qom/object.h +3 -0
@@ -984,6 +984,9 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
   * @include_abstract: Whether to include abstract classes.
   *
   * Returns: A singly-linked list of the classes in reverse hashtable order.
+ *
+ * The returned list must be released with g_slist_free()
+ * when no longer required.

I'd suggest

Quoted 5 lines
Quoted 2 lines

"The returned list, but not its elements, must be released with
g_slist_free() or g_autoptr when no longer required"

As gobject-introspection annotations: "Returns: (transfer container) (element-type ObjectClass): A list of #ObjectClass"

Are you suggesting to replace "Returns: A singly-linked list of the classes in reverse hashtable order." by the line you quoted?

Quoted 30 lines
Quoted 28 lines
Quoted 16 lines
include/qom/object.h +3 -1
   */
  GSList *object_class_get_list(const char *implements_type,
                                bool include_abstract);
@@ -995,6 +998,9 @@ GSList *object_class_get_list(const char *implements_type,
   *
   * Returns: A singly-linked list of the classes in alphabetical
   * case-insensitive order.
+ *
+ * The returned list must be released with g_slist_free()
+ * when no longer required.
   */
  GSList *object_class_get_list_sorted(const char *implements_type,
                                bool include_abstract);
--
Quoted 3 lines

2.21.1

Regards,
Daniel
--

|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#4 lore raw

Hi

Quoted 29 lines · Philippe Mathieu-Daudé
Quoted 27 lines · Marc-André Lureau

Hi

Quoted 24 lines · Daniel P. Berrangé
Quoted 13 lines · Philippe Mathieu-Daudé

Document the list returned by object_class_get_list() must be released with g_slist_free() to avoid memory leaks.

---
  include/qom/object.h | 6 ++++++
  1 file changed, 6 insertions(+)
include/qom/object.h +0 -0
index 29546496c1..5517b56508 100644

include/qom/object.h void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), · line 989

Quoted 6 lines
include/qom/object.h +3 -0
@@ -984,6 +984,9 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
   * @include_abstract: Whether to include abstract classes.
   *
   * Returns: A singly-linked list of the classes in reverse hashtable order.
+ *
+ * The returned list must be released with g_slist_free()
+ * when no longer required.

I'd suggest

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

"The returned list, but not its elements, must be released with
g_slist_free() or g_autoptr when no longer required"

As gobject-introspection annotations: "Returns: (transfer container) (element-type ObjectClass): A list of #ObjectClass"

Are you suggesting to replace "Returns: A singly-linked list of the classes in reverse hashtable order." by the line you quoted?

No, just a remark. I doubt this is compatible with kernel-doc at this point, and we are not using GI.

fwiw, I don't think "in reverse hashtable order" is really meaningful anyway.

Quoted 32 lines
Quoted 31 lines
Quoted 29 lines
Quoted 17 lines
include/qom/object.h +3 -1
   */
  GSList *object_class_get_list(const char *implements_type,
                                bool include_abstract);
@@ -995,6 +998,9 @@ GSList *object_class_get_list(const char *implements_type,
   *
   * Returns: A singly-linked list of the classes in alphabetical
   * case-insensitive order.
+ *
+ * The returned list must be released with g_slist_free()
+ * when no longer required.
   */
  GSList *object_class_get_list_sorted(const char *implements_type,
                                bool include_abstract);
--
Quoted 3 lines

2.21.1

Regards,
Daniel
--

|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Signature · 1 line
Marc-André Lureau
#5 lore raw
In reply to Marc-André Lureau
Quoted 27 lines · Marc-André Lureau

Hi

Quoted 24 lines · Daniel P. Berrangé
Quoted 13 lines · Philippe Mathieu-Daudé

Document the list returned by object_class_get_list() must be released with g_slist_free() to avoid memory leaks.

---
 include/qom/object.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/qom/object.h +0 -0
index 29546496c1..5517b56508 100644

include/qom/object.h void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), · line 989

Quoted 6 lines
include/qom/object.h +3 -0
@@ -984,6 +984,9 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
  * @include_abstract: Whether to include abstract classes.
  *
  * Returns: A singly-linked list of the classes in reverse hashtable order.
+ *
+ * The returned list must be released with g_slist_free()
+ * when no longer required.

I'd suggest

Quoted 5 lines
Quoted 2 lines

"The returned list, but not its elements, must be released with
g_slist_free() or g_autoptr when no longer required"

As gobject-introspection annotations: "Returns: (transfer container) (element-type ObjectClass): A list of #ObjectClass"

If we were using Gobject introspection and/or Gtk-Doc, then I'd certainly suggest that syntax, but AFAIK this is not something that fits with our intented docs tools. There might be sense in having our docs tools parse these kind of annotations as it is useful to have it in standardized format. I think we should decide on this before actually adding them to the docs though.

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|