[X2Go-Commits] [x2goclient] 01/02: src/x2goclient.cpp: no need to put new_argv_c_str std::vector onto the heap.

git-admin at x2go.org git-admin at x2go.org
Mon Jan 23 17:05:02 CET 2017


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository x2goclient.

commit 253b2abae6148033effcd50c21e18a1df532c911
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Mon Jan 23 16:49:14 2017 +0100

    src/x2goclient.cpp: no need to put new_argv_c_str std::vector onto the heap.
    
    Keep it on the stack.
---
 debian/changelog   |    2 ++
 src/x2goclient.cpp |    8 ++++----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index d9d2a5d..d608793 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -547,6 +547,8 @@ x2goclient (4.1.0.0-0x2go1) UNRELEASED; urgency=medium
       and add comments/requests for re-translations for the next time.
     - macbuild.sh: switch to bundling PulseAudio 10.0 since it's now available
       in MacPorts.
+    - src/x2goclient.cpp: no need to put new_argv_c_str std::vector onto the
+      heap. Keep it on the stack.
 
   [ Bernard Cafarelli ]
   * New upstream version (4.1.0.0):
diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp
index 426a204..b25d0ce 100644
--- a/src/x2goclient.cpp
+++ b/src/x2goclient.cpp
@@ -48,16 +48,16 @@ int fork_helper (int argc, char **argv) {
     new_argv.push_back (std::string (argv[0]));
     new_argv.push_back ("--unixhelper");
 
-    std::vector<char *> *new_argv_c_str = new (std::vector<char *>) ();
+    std::vector<char *> new_argv_c_str;
     for (std::vector<std::string>::iterator it = new_argv.begin (); it != new_argv.end (); ++it) {
       const char *elem = (*it).c_str ();
-      new_argv_c_str->push_back (strndup (elem, std::strlen (elem)));
+      new_argv_c_str.push_back (strndup (elem, std::strlen (elem)));
     }
 
     /* Add null pointer as last element. */
-    new_argv_c_str->push_back (0);
+    new_argv_c_str.push_back (0);
 
-    if (0 != execv (new_argv_c_str->front (), &(new_argv_c_str->front ()))) {
+    if (0 != execv (new_argv_c_str.front (), &(new_argv_c_str.front ()))) {
       const int saved_errno = errno;
       std::cerr << "Failed to re-execute process as UNIX cleanup helper tool: " << std::strerror (saved_errno) << "\n"
                 << "Terminating and killing parent." << "\n"

--
Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git


More information about the x2go-commits mailing list