File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed
bindings/python/google_benchmark Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -17,14 +17,13 @@ std::vector<std::string> Initialize(const std::vector<std::string>& argv) {
17
17
// The `argv` pointers here become invalid when this function returns, but
18
18
// benchmark holds the pointer to `argv[0]`. We create a static copy of it
19
19
// so it persists, and replace the pointer below.
20
- static std::string executable_name (argv[0 ]);
21
- std::vector< char *> ptrs ;
22
- ptrs. reserve (argv. size () );
23
- for (auto & arg : argv) {
24
- ptrs. push_back ( const_cast <char *>(arg .c_str () ));
20
+ static std::string executable_name (argv. empty () ? " unknown " : argv [0 ]);
21
+ int argc = static_cast < int >( std::max (std:: size_t { 1 }, argv. size ())) ;
22
+ std::vector< char *> ptrs (argc );
23
+ for (size_t i = 0 ; i < argv. size (); ++i ) {
24
+ ptrs[i] = const_cast <char *>(argv[i] .c_str ());
25
25
}
26
26
ptrs[0 ] = const_cast <char *>(executable_name.c_str ());
27
- int argc = static_cast <int >(argv.size ());
28
27
benchmark::Initialize (&argc, ptrs.data ());
29
28
std::vector<std::string> remaining_argv;
30
29
remaining_argv.reserve (argc);
You can’t perform that action at this time.
0 commit comments