[PATCH xorg-gtest 13/16] xserver: use new Process::Start(vector) call to populate argument list
There's probably some better way to do this than strdup()ing everything, send me a patch if you know how. Signed-off-by: Peter Hutterer peter.hutte...@who-t.net --- src/xserver.cpp | 24 ++-- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/xserver.cpp b/src/xserver.cpp index 765feb1..cc78d59 100644 --- a/src/xserver.cpp +++ b/src/xserver.cpp @@ -301,13 +301,25 @@ unsigned int xorg::testing::XServer::Start(void) { } unsigned int xorg::testing::XServer::Start(std::string program) { + std::vectorchar* args; + std::mapstd::string, std::string::iterator it; + TestStartup(); - Process::Start(program, program.c_str(), - GetDisplayString(), - -logverbose, 10, - -logfile, d_-options[-logfile].c_str(), - -config, d_-options[-config].c_str(), - NULL); + + args.push_back(strdup(program.c_str())); + args.push_back(strdup(GetDisplayString())); + + for (it = d_-options.begin(); it != d_-options.end(); it++) { +args.push_back(strdup(it-first.c_str())); +if (it-second.length()) + args.push_back(strdup(it-second.c_str())); + } + + Process::Start(program, args); + + std::vectorchar*::iterator vit; + for (vit = args.begin(); vit != args.end(); vit++) +free(*vit); /* FIXME: use -displayfd here once the released servers support it */ return d_-display_number; -- 1.7.10.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xorg-gtest 13/16] xserver: use new Process::Start(vector) call to populate argument list
On 07/02/2012 11:44 PM, Peter Hutterer wrote: There's probably some better way to do this than strdup()ing everything, send me a patch if you know how. Hopefully it will be easier if we use a vector of std::strings, as I mentioned in the previous patch review :). Signed-off-by: Peter Hutterer peter.hutte...@who-t.net --- src/xserver.cpp | 24 ++-- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/xserver.cpp b/src/xserver.cpp index 765feb1..cc78d59 100644 --- a/src/xserver.cpp +++ b/src/xserver.cpp @@ -301,13 +301,25 @@ unsigned int xorg::testing::XServer::Start(void) { } unsigned int xorg::testing::XServer::Start(std::string program) { + std::vectorchar* args; + std::mapstd::string, std::string::iterator it; + TestStartup(); - Process::Start(program, program.c_str(), - GetDisplayString(), - -logverbose, 10, - -logfile, d_-options[-logfile].c_str(), - -config, d_-options[-config].c_str(), - NULL); + + args.push_back(strdup(program.c_str())); + args.push_back(strdup(GetDisplayString())); + + for (it = d_-options.begin(); it != d_-options.end(); it++) { +args.push_back(strdup(it-first.c_str())); +if (it-second.length()) + args.push_back(strdup(it-second.c_str())); + } + + Process::Start(program, args); + + std::vectorchar*::iterator vit; + for (vit = args.begin(); vit != args.end(); vit++) +free(*vit); /* FIXME: use -displayfd here once the released servers support it */ return d_-display_number; ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel