From fd1fbef2dd74c22714ed5fa81e40eff3f55557e5 Mon Sep 17 00:00:00 2001 From: "Andrew V. Samoilov" Date: Fri, 26 Nov 2004 11:14:07 +0000 Subject: [PATCH] * execute.c (shell_execute): Optimize memory usage. --- src/ChangeLog | 4 ++++ src/execute.c | 13 ++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 811793329..6d4272101 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2004-11-26 Andrew V. Samoilov + + * execute.c (shell_execute): Optimize memory usage. + 2004-11-02 Pavel Tsekov * help.c (help_event): Fix offset of event area for mouse click. diff --git a/src/execute.c b/src/execute.c index 2dd7486b8..2ff3a4498 100644 --- a/src/execute.c +++ b/src/execute.c @@ -174,26 +174,25 @@ do_execute (const char *shell, const char *command, int flags) void shell_execute (const char *command, int flags) { - char *cmd; + char *cmd = NULL; - if(flags & EXECUTE_HIDE) { + if (flags & EXECUTE_HIDE) { cmd = g_strconcat (" ", command, (char *) NULL); flags ^= EXECUTE_HIDE; - } else - cmd = g_strdup(command); + } #ifdef HAVE_SUBSHELL_SUPPORT if (use_subshell) if (subshell_state == INACTIVE) - do_execute (shell, cmd, flags | EXECUTE_AS_SHELL); + do_execute (shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL); else message (1, MSG_ERROR, _(" The shell is already running a command ")); else #endif /* HAVE_SUBSHELL_SUPPORT */ - do_execute (shell, cmd, flags | EXECUTE_AS_SHELL); + do_execute (shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL); - g_free(cmd); + g_free (cmd); }