Add a note about casting the results of g_new() and g_new0().
authorMatthias Clasen <mclasen@redhat.com>
Wed, 18 Jan 2006 03:51:39 +0000 (03:51 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Wed, 18 Jan 2006 03:51:39 +0000 (03:51 +0000)
2006-01-17  Matthias Clasen  <mclasen@redhat.com>

* glib/tmpl/memory.sgml: Add a note about casting the results
of g_new() and g_new0().

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
docs/reference/ChangeLog
docs/reference/glib/tmpl/memory.sgml
glib/gkeyfile.c

index 595bb98bc4a840b33c74a0ab95f7ccf12f8bdb1c..69de733019c3dd6e2598064a2d75d9aeac707e51 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-01-17  Matthias Clasen  <mclasen@redhat.com>
+
+       * glib/gkeyfile.c (g_key_file_get_groups): Correct a g_new0()
+       call.  (#327421, Morten Welinder)
+
 2006-01-17  Sebastian Wilhelmi  <seppi@seppi.de>
 
        * glib/gthreadpool.c: To avoid deadlocks get rid of the settings
index 595bb98bc4a840b33c74a0ab95f7ccf12f8bdb1c..69de733019c3dd6e2598064a2d75d9aeac707e51 100644 (file)
@@ -1,3 +1,8 @@
+2006-01-17  Matthias Clasen  <mclasen@redhat.com>
+
+       * glib/gkeyfile.c (g_key_file_get_groups): Correct a g_new0()
+       call.  (#327421, Morten Welinder)
+
 2006-01-17  Sebastian Wilhelmi  <seppi@seppi.de>
 
        * glib/gthreadpool.c: To avoid deadlocks get rid of the settings
index 595bb98bc4a840b33c74a0ab95f7ccf12f8bdb1c..69de733019c3dd6e2598064a2d75d9aeac707e51 100644 (file)
@@ -1,3 +1,8 @@
+2006-01-17  Matthias Clasen  <mclasen@redhat.com>
+
+       * glib/gkeyfile.c (g_key_file_get_groups): Correct a g_new0()
+       call.  (#327421, Morten Welinder)
+
 2006-01-17  Sebastian Wilhelmi  <seppi@seppi.de>
 
        * glib/gthreadpool.c: To avoid deadlocks get rid of the settings
index 4a6ca41489cbb9a7473d297aa0877204031d90e9..51d51a67e63f311c596e889dd15dd05be5582875 100644 (file)
@@ -1,3 +1,8 @@
+2006-01-17  Matthias Clasen  <mclasen@redhat.com>
+
+       * glib/tmpl/memory.sgml: Add a note about casting the results
+       of g_new() and g_new0().
+
 2006-01-16  Matthias Clasen  <mclasen@redhat.com>
 
        * === Released 2.9.3 ===
index 063b7a94957ed982bd78d723e2ae53f161fb5a9a..98053225b8dce62dc11e51420a50bc0414a652da 100644 (file)
@@ -29,6 +29,11 @@ Allocates @n_structs elements of type @struct_type.
 The returned pointer is cast to a pointer to the given type.
 If @n_structs is 0 it returns %NULL.
 </para>
+<para>
+Since the returned pointer is already casted to the right type,
+it is normally unnecessary to cast it explicitly, and doing
+so might hide memory allocation errors.
+</para>
 
 @struct_type: the type of the elements to allocate.
 @n_structs: the number of elements to allocate.
@@ -41,6 +46,11 @@ Allocates @n_structs elements of type @struct_type, initialized to 0's.
 The returned pointer is cast to a pointer to the given type.
 If @n_structs is 0 it returns %NULL.
 </para>
+<para>
+Since the returned pointer is already casted to the right type,
+it is normally unnecessary to cast it explicitly, and doing
+so might hide memory allocation errors.
+</para>
 
 @struct_type: the type of the elements to allocate.
 @n_structs: the number of elements to allocate.
index d77a1ae1678baa835f5701e9422f1c5d87125e2d..7a8a7832b814eff073c2da4b7994b3a9a3356e0a 100644 (file)
@@ -1107,7 +1107,7 @@ g_key_file_get_groups (GKeyFile *key_file,
    * list) is always the comment group at the top,
    * which we skip
    */
-  groups = (gchar **) g_new0 (gchar **, num_groups);
+  groups = g_new0 (gchar *, num_groups);
 
   group_node = g_list_last (key_file->groups);