[glib] More gio-du win32 fixes



commit abf505fd0e6ae5c353de24621adbf56a083d4e66
Author: Ryan Lortie <desrt desrt ca>
Date:   Mon Sep 23 16:29:24 2013 -0400

    More gio-du win32 fixes
    
    Don't free the utf8 filename before the async function completes.
    
    also, gitignore

 gio/tests/.gitignore |    1 +
 gio/tests/gio-du.c   |    9 ++++-----
 2 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/gio/tests/.gitignore b/gio/tests/.gitignore
index 99e8837..3bd3a2f 100644
--- a/gio/tests/.gitignore
+++ b/gio/tests/.gitignore
@@ -69,6 +69,7 @@ gdbus-test-codegen-generated*
 gdbus-test-fixture
 gdbus-testserver
 gdbus-threading
+gio-du
 g-file
 g-file-info
 g-icon
diff --git a/gio/tests/gio-du.c b/gio/tests/gio-du.c
index a33cf73..3454108 100644
--- a/gio/tests/gio-du.c
+++ b/gio/tests/gio-du.c
@@ -58,7 +58,7 @@ async_ready_func (GObject      *source,
                   GAsyncResult *result,
                   gpointer      user_data)
 {
-  const gchar *filename = user_data;
+  gchar *filename = user_data;
   GError *error = NULL;
   guint64 disk_usage;
   guint64 num_dirs;
@@ -67,6 +67,7 @@ async_ready_func (GObject      *source,
   g_file_measure_disk_usage_finish (G_FILE (source), result, &disk_usage, &num_dirs, &num_files, &error);
   print_result (filename, disk_usage, num_dirs, num_files, error, '\n');
   outstanding_asyncs--;
+  g_free (filename);
 }
 
 static void
@@ -143,7 +144,7 @@ main (int argc, char **argv)
 #else
   while (argv[i])
   {
-    gchar *argv_utf8 = argv[i];
+    gchar *argv_utf8 = g_strdup (argv[i]);
 #endif
     GFile *file = g_file_new_for_commandline_arg (argv_utf8);
 
@@ -163,12 +164,10 @@ main (int argc, char **argv)
       g_file_measure_disk_usage (file, flags, NULL, progress, argv_utf8,
                                  &disk_usage, &num_dirs, &num_files, &error);
       print_result (argv_utf8, disk_usage, num_dirs, num_files, error, '\n');
+      g_free (argv_utf8);
     }
 
     g_object_unref (file);
-#ifdef G_OS_WIN32
-    g_free (argv_utf8);
-#endif
 
     i++;
   }


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