@@ -630,13 +630,13 @@ bool DeathTestImpl::Passed(bool status_ok) {
630
630
#ifndef GTEST_OS_WINDOWS
631
631
// Note: The return value points into args, so the return value's lifetime is
632
632
// bound to that of args.
633
- static std::unique_ptr <char *[] > CreateArgvFromArgs (
634
- std::vector<std::string>& args) {
635
- auto result = std::make_unique< char *[]> (args.size () + 1 );
636
- for (size_t i = 0 ; i < args. size (); ++i ) {
637
- result[i] = &args[i][ 0 ] ;
633
+ static std::vector <char *> CreateArgvFromArgs (std::vector<std::string>& args) {
634
+ std::vector<char *> result;
635
+ result. reserve (args.size () + 1 );
636
+ for (auto & arg : args) {
637
+ result. push_back (&arg[ 0 ]) ;
638
638
}
639
- result[args. size ()] = nullptr ; // extra null terminator
639
+ result. push_back ( nullptr ) ; // Extra null terminator.
640
640
return result;
641
641
}
642
642
#endif
@@ -1036,8 +1036,8 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() {
1036
1036
// "Fuchsia Test Component" which contains a "Fuchsia Component Manifest")
1037
1037
// Launching processes is a privileged operation in Fuchsia, and the
1038
1038
// declaration indicates that the ability is required for the component.
1039
- std::unique_ptr <char *[] > argv = CreateArgvFromArgs (args);
1040
- status = fdio_spawn_etc (child_job, FDIO_SPAWN_CLONE_ALL, argv[0 ], argv.get (),
1039
+ std::vector <char *> argv = CreateArgvFromArgs (args);
1040
+ status = fdio_spawn_etc (child_job, FDIO_SPAWN_CLONE_ALL, argv[0 ], argv.data (),
1041
1041
nullptr , 2 , spawn_actions,
1042
1042
child_process_.reset_and_get_address (), nullptr );
1043
1043
GTEST_DEATH_TEST_CHECK_ (status == ZX_OK);
@@ -1388,8 +1388,8 @@ DeathTest::TestRole ExecDeathTest::AssumeRole() {
1388
1388
// is necessary.
1389
1389
FlushInfoLog ();
1390
1390
1391
- std::unique_ptr <char *[] > argv = CreateArgvFromArgs (args);
1392
- const pid_t child_pid = ExecDeathTestSpawnChild (argv.get (), pipe_fd[0 ]);
1391
+ std::vector <char *> argv = CreateArgvFromArgs (args);
1392
+ const pid_t child_pid = ExecDeathTestSpawnChild (argv.data (), pipe_fd[0 ]);
1393
1393
GTEST_DEATH_TEST_CHECK_SYSCALL_ (close (pipe_fd[1 ]));
1394
1394
set_child_pid (child_pid);
1395
1395
set_read_fd (pipe_fd[0 ]);
0 commit comments