From: Gabriel Corona Date: Fri, 20 May 2016 07:53:05 +0000 (+0200) Subject: Use new/delete for smx_process_arg_t X-Git-Tag: v3_14~1190 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/656d24a575ca26a64c94174ff3573272979e081d Use new/delete for smx_process_arg_t --- diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index 985bdcd404..15ffa679fc 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -166,7 +166,7 @@ void _SIMIX_host_free_process_arg(void *data) xbt_free(arg->argv[i]); xbt_free(arg->argv); xbt_free(arg->name); - xbt_free(arg); + delete arg; } /** * \brief Add a process to the list of the processes that the host will restart when it comes back @@ -188,7 +188,7 @@ void SIMIX_host_add_auto_restart_process(sg_host_t host, if (!sg_host_simix(host)->auto_restart_processes) { sg_host_simix(host)->auto_restart_processes = xbt_dynar_new(sizeof(smx_process_arg_t),_SIMIX_host_free_process_arg); } - smx_process_arg_t arg = xbt_new(s_smx_process_arg_t,1); + smx_process_arg_t arg = new s_smx_process_arg_t(); arg->name = xbt_strdup(name); arg->code = code; arg->data = data; diff --git a/src/simix/smx_process.cpp b/src/simix/smx_process.cpp index 08644bbc77..f696d92b30 100644 --- a/src/simix/smx_process.cpp +++ b/src/simix/smx_process.cpp @@ -219,7 +219,7 @@ smx_process_t SIMIX_process_create_from_wrapper(smx_process_arg_t args) { args->properties, args->auto_restart, NULL); - xbt_free(args); + delete args; return process; } diff --git a/src/simix/smx_process_private.h b/src/simix/smx_process_private.h index bf93b7fe76..099821dcd4 100644 --- a/src/simix/smx_process_private.h +++ b/src/simix/smx_process_private.h @@ -17,7 +17,8 @@ typedef struct s_smx_process_exit_fun { void *arg; } s_smx_process_exit_fun_t, *smx_process_exit_fun_t; -typedef struct s_smx_process_arg { +typedef class s_smx_process_arg { +public: char *name; xbt_main_func_t code; void *data; diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index effdb4b3fa..da1123517a 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -575,7 +575,7 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process) smx_process_arg_t arg = NULL; smx_process_t process_created = NULL; - arg = xbt_new0(s_smx_process_arg_t, 1); + arg = new s_smx_process_arg_t(); arg->code = parse_code; arg->data = NULL; arg->hostname = sg_host_get_name(host); @@ -593,7 +593,7 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process) xbt_dynar_push_as(sg_host_simix(host)->boot_processes,smx_process_arg_t,arg); if (start_time > SIMIX_get_clock()) { - arg = xbt_new0(s_smx_process_arg_t, 1); + arg = new s_smx_process_arg_t(); arg->name = (char*)(process->argv)[0]; arg->code = parse_code; arg->data = NULL;