[gnome-builder] gui: use g_new0()



commit 5f1afb3e6f3dbf20fd55c07d4e5cabff3d788cce
Author: Christian Hergert <chergert redhat com>
Date:   Sat Jul 31 09:55:08 2021 -0700

    gui: use g_new0()
    
    We always try to start with zero allocated structs even if we overwrite
    all the members in all but the most delecate of tight loops.

 src/libide/gui/ide-marked-view.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
---
diff --git a/src/libide/gui/ide-marked-view.c b/src/libide/gui/ide-marked-view.c
index f29977043..b868e8a12 100644
--- a/src/libide/gui/ide-marked-view.c
+++ b/src/libide/gui/ide-marked-view.c
@@ -209,13 +209,12 @@ render_node(GString          *out,
         {
           g_autofree struct list_context *list = NULL;
 
-          list = g_malloc (sizeof (struct list_context));
-
+          list = g_new0 (struct list_context, 1);
           list->list_type = cmark_node_get_list_type (node);
+          list->next_elem_number = cmark_node_get_list_start (node);
 
           g_return_val_if_fail (list->list_type != CMARK_NO_LIST, FALSE);
 
-          list->next_elem_number = cmark_node_get_list_start (node);
           g_queue_push_tail (list_stack, g_steal_pointer (&list));
         }
       else


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]