]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
dbus-spawn-win.c: Move out argv copy from DBusSitter struct
authorRalf Habacker <ralf.habacker@freenet.de>
Fri, 21 Dec 2018 15:38:02 +0000 (16:38 +0100)
committerRalf <ralf@linux1.fritz.box>
Sat, 5 Jan 2019 10:41:58 +0000 (11:41 +0100)
Since the child program is started in the main thread, there is no
need to pass a copy of argv to the thread waiting for the child's
termination.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
dbus/dbus-spawn-win.c

index ee03102f15e5cbc08520bf4d91c823e3423c9456..9cfdf478fa38c0d6b78b419516e8f6ff709a6c42 100644 (file)
@@ -66,9 +66,6 @@ struct DBusBabysitter
 
     char *log_name;
 
-    int argc;
-    char **argv;
-
     HANDLE thread_handle;
     HANDLE child_handle;
     DBusSocket socket_to_babysitter;   /* Connection to the babysitter thread */
@@ -124,9 +121,6 @@ _dbus_babysitter_new (void)
 
   sitter->socket_to_babysitter = sitter->socket_to_main = _dbus_socket_get_invalid ();
 
-  sitter->argc = 0;
-  sitter->argv = NULL;
-
   sitter->watches = _dbus_watch_list_new ();
   if (sitter->watches == NULL)
     {
@@ -189,7 +183,6 @@ close_socket_to_babysitter (DBusBabysitter *sitter)
 void
 _dbus_babysitter_unref (DBusBabysitter *sitter)
 {
-  int i;
   dbus_int32_t old_refcount;
 
   PING();
@@ -209,19 +202,6 @@ _dbus_babysitter_unref (DBusBabysitter *sitter)
           sitter->socket_to_main.sock = INVALID_SOCKET;
         }
 
-      PING();
-      if (sitter->argv != NULL)
-        {
-          for (i = 0; i < sitter->argc; i++)
-            if (sitter->argv[i] != NULL)
-              {
-                dbus_free (sitter->argv[i]);
-                sitter->argv[i] = NULL;
-              }
-          dbus_free (sitter->argv);
-          sitter->argv = NULL;
-        }
-
       if (sitter->child_handle != NULL)
         {
           CloseHandle (sitter->child_handle);
@@ -633,6 +613,8 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter           **sitter_p,
   DBusBabysitter *sitter;
   DWORD sitter_thread_id;
   HANDLE handle;
+  int argc;
+  char **my_argv = NULL;
 
   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
   _dbus_assert (argv[0] != NULL);
@@ -693,19 +675,22 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter           **sitter_p,
       goto out0;
     }
 
-  sitter->argc = protect_argv (argv, &sitter->argv);
-  if (sitter->argc == -1)
+  argc = protect_argv (argv, &my_argv);
+  if (argc == -1)
     {
       _DBUS_SET_OOM (error);
       goto out0;
     }
 
-  PING();
-  _dbus_verbose ("babysitter: spawn child '%s'\n", sitter->argv[0]);
+  _dbus_verbose ("babysitter: spawn child '%s'\n", my_argv[0]);
 
   PING();
-  handle = _dbus_spawn_program (sitter->log_name, sitter->argv,
-                                (char **) envp);
+  handle = _dbus_spawn_program (sitter->log_name, my_argv, (char **) envp);
+
+  if (my_argv != NULL)
+    {
+      dbus_free_string_array (my_argv);
+    }
 
   PING();
   if (handle != INVALID_HANDLE_VALUE)