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 595bb98..69de733 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 595bb98..69de733 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 595bb98..69de733 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 4a6ca41..51d51a6 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 063b7a9..9805322 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 d77a1ae..7a8a783 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);