[gnome-commander] gnome-cmd-file-list.cc: initialize GList with nullptr



commit e8f0a559033202da84ef3379a10552c1cb395355
Author: Mamoru TASAKA <mtasaka fedoraproject org>
Date:   Thu Mar 18 22:34:05 2021 +0900

    gnome-cmd-file-list.cc: initialize GList with nullptr
    
    As written on:
    https://developer.gnome.org/glib/stable/glib-Doubly-Linked-Lists.html
    nullptr is a valid GList initializer. Also, g_list_free() tries to free
    memory used by a GList and return the buffer to GLib slice allocator,
    so GList must not be created by new operator.

 src/gnome-cmd-file-list.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index 482bb1a3..fb23d1e6 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -1210,7 +1210,7 @@ static void do_mime_exec_single (gpointer *args)
     auto dpath = (gchar *) args[2];
 
     auto gnomeCmdFile = gnome_cmd_file_new(path);
-    auto gFileList = new GList();
+    GList *gFileList = nullptr;
     gFileList = g_list_append(gFileList, gnomeCmdFile->gFile);
     g_app_info_launch (gnomeCmdFile->GetAppInfoForContentType(), gFileList, nullptr, nullptr);
 
@@ -1332,7 +1332,7 @@ static void mime_exec_single (GnomeCmdFile *f)
 
     if (f->is_local())
     {
-        auto gFileList = new GList();
+        GList *gFileList = nullptr;
         gFileList = g_list_append(gFileList, f->gFile);
         g_app_info_launch (gAppInfo, gFileList, nullptr, nullptr);
         g_list_free(gFileList);
@@ -1342,7 +1342,7 @@ static void mime_exec_single (GnomeCmdFile *f)
         if (gnome_cmd_app_get_handles_uris (app) && gnome_cmd_data.options.honor_expect_uris)
         {
             auto gFileFromUri = g_file_new_for_uri(f->get_uri_str());
-            auto gFileList = new GList();
+            GList *gFileList = nullptr;
             gFileList = g_list_append(gFileList, gFileFromUri);
             g_app_info_launch (gAppInfo, gFileList, nullptr, nullptr);
             g_object_unref(gFileFromUri);


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