Skip to content

Commit 1c9983b

Browse files
authored
Refactoring build_interpreter function (#31)
1 parent 213eef1 commit 1c9983b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/xutils.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,16 @@ namespace xcpp
8282

8383
interpreter_ptr build_interpreter(int argc, char** argv)
8484
{
85-
int interpreter_argc = argc; // + 1;
86-
const char** interpreter_argv = new const char*[interpreter_argc];
85+
std::vector<const char*> interpreter_argv(argc);
8786
interpreter_argv[0] = "xeus-cpp";
88-
// Copy all arguments in the new array excepting the process name.
87+
88+
// Copy all arguments in the new vector excepting the process name.
8989
for (int i = 1; i < argc; i++)
9090
{
9191
interpreter_argv[i] = argv[i];
9292
}
9393

94-
interpreter_ptr interp_ptr = std::make_unique<interpreter>(interpreter_argc, interpreter_argv);
95-
delete[] interpreter_argv;
94+
interpreter_ptr interp_ptr = std::make_unique<interpreter>(argc, interpreter_argv.data());
9695
return interp_ptr;
9796
}
9897

0 commit comments

Comments
 (0)