From: Ralf Habacker Date: Fri, 21 Dec 2018 15:38:02 +0000 (+0100) Subject: dbus-spawn-win.c: Move out argv copy from DBusSitter struct X-Git-Tag: dbus-1.13.10~28^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=61c76cae028686e558bca2059f11c8ae3129b871;p=thirdparty%2Fdbus.git dbus-spawn-win.c: Move out argv copy from DBusSitter struct 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 --- diff --git a/dbus/dbus-spawn-win.c b/dbus/dbus-spawn-win.c index ee03102f1..9cfdf478f 100644 --- a/dbus/dbus-spawn-win.c +++ b/dbus/dbus-spawn-win.c @@ -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)