if (not host)
THROWF(arg_error, 0, "Host '%s' unknown", process_host);
process.host = process_host;
-
- process.argc = 1 + xbt_dynar_length(arguments);
- process.argv = static_cast<const char**>(xbt_new(const char*, process.argc + 1));
- process.argv[0] = xbt_strdup(process_function);
+ process.args.push_back(process_function);
/* add arguments */
unsigned int i;
char *arg;
xbt_dynar_foreach(arguments, i, arg) {
- process.argv[i + 1] = xbt_strdup(arg);
+ process.args.push_back(arg);
}
- process.argv[process.argc] = nullptr;
// Check we know how to handle this function name:
simgrid::simix::ActorCodeFactory& parse_code = SIMIX_get_actor_code_factory(process_function);
double kill_time = process->kill_time;
int auto_restart = process->on_failure == SURF_ACTOR_ON_FAILURE_DIE ? 0 : 1;
- std::vector<std::string> args(process->argv, process->argv + process->argc);
- std::function<void()> code = factory(std::move(args));
+ std::string process_name = process->args[0];
+ std::function<void()> code = factory(std::move(process->args));
std::shared_ptr<std::map<std::string, std::string>> properties(process->properties);
smx_process_arg_t arg = nullptr;
arg = new simgrid::simix::ProcessArg();
- arg->name = std::string(process->argv[0]);
+ arg->name = process_name;
arg->code = code;
arg->data = nullptr;
arg->host = host;
if (start_time > SIMIX_get_clock()) {
arg = new simgrid::simix::ProcessArg();
- arg->name = std::string(process->argv[0]);
+ arg->name = process_name;
arg->code = std::move(code);
arg->data = nullptr;
arg->host = host;
};
struct s_sg_platf_process_cbarg_t {
- const char** argv = nullptr;
- int argc = 0;
+ std::vector<std::string> args;
std::map<std::string, std::string>* properties = nullptr;
const char* host = nullptr;
const char* function = nullptr;
current_property_set = nullptr;
}
-static int argc;
-static char **argv;
+static std::vector<std::string> arguments;
void STag_surfxml_process()
{
void STag_surfxml_actor()
{
ZONE_TAG = 0;
- argc = 1;
- argv = xbt_new(char *, 1);
- argv[0] = xbt_strdup(A_surfxml_actor_function);
+ arguments.assign(1, A_surfxml_actor_function);
xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
}
actor.properties = current_property_set;
current_property_set = nullptr;
- actor.argc = argc;
- actor.argv = (const char **)argv;
+ actor.args.swap(arguments);
actor.host = A_surfxml_actor_host;
actor.function = A_surfxml_actor_function;
actor.start_time = surf_parse_get_double(A_surfxml_actor_start___time);
}
sg_platf_new_process(&actor);
-
- for (int i = 0; i != argc; ++i)
- xbt_free(argv[i]);
- xbt_free(argv);
- argv = nullptr;
}
void STag_surfxml_argument(){
- argc++;
- argv = (char**)xbt_realloc(argv, (argc) * sizeof(char **));
- argv[(argc) - 1] = xbt_strdup(A_surfxml_argument_value);
+ arguments.push_back(A_surfxml_argument_value);
}
void STag_surfxml_model___prop(){