[PATCH xorg-gtest 13/16] xserver: use new Process::Start(vector) call to populate argument list

Chase Douglas chase.douglas at canonical.com
Tue Jul 3 11:16:25 PDT 2012


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.hutterer at 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::vector<char*> args;
> +  std::map<std::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::vector<char*>::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;
>



More information about the xorg-devel mailing list