From b33b8131fd85fe7cf54934500e421d96efcd801b Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 4 Oct 2009 18:18:32 +0000 Subject: cleaned new exec script function --- src/sysExec.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/sysExec.cpp') diff --git a/src/sysExec.cpp b/src/sysExec.cpp index ca62dfd..104581e 100644 --- a/src/sysExec.cpp +++ b/src/sysExec.cpp @@ -107,19 +107,14 @@ void anytun_exec(std::string const& script, StringVector const& args, StringList argv[args.size() + 1] = NULL; char** evp; - if(env.size()) { - evp = new char*[env.size() + 1]; - unsigned int i = 0; - for(StringList::const_iterator it = env.begin(); it != env.end(); ++it) { - evp[i] = new char[it->size() + 1]; - std::strcpy(evp[i], it->c_str()); - ++i; - } - evp[env.size()] = NULL; - } else { - evp = new char*[1]; - evp[0] = NULL; + evp = new char*[env.size() + 1]; + unsigned int i = 0; + for(StringList::const_iterator it = env.begin(); it != env.end(); ++it) { + evp[i] = new char[it->size() + 1]; + std::strcpy(evp[i], it->c_str()); + ++i; } + evp[env.size()] = NULL; execve(script.c_str(), argv, evp); // if execve returns, an error occurred, but logging doesn't work -- cgit v1.2.3