From: Arnaud Giersch Date: Thu, 10 Oct 2013 10:10:52 +0000 (+0200) Subject: Chasing more leaks. X-Git-Tag: v3_9_90~27 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/8985a1134de89a845dd5fb959c9a1fe776b890bf?ds=sidebyside Chasing more leaks. --- diff --git a/src/simix/smx_host.c b/src/simix/smx_host.c index a168ccf1db..2480bbdcf2 100644 --- a/src/simix/smx_host.c +++ b/src/simix/smx_host.c @@ -262,10 +262,14 @@ void* SIMIX_host_get_data(smx_host_t host){ return SIMIX_host_priv(host)->data; } -void _SIMIX_host_free_process_arg(void *); -void _SIMIX_host_free_process_arg(void *data) + +static void _SIMIX_host_free_process_arg(void *data) { smx_process_arg_t arg = *(void**)data; + int i; + for (i = 0; i < arg->argc; i++) + xbt_free(arg->argv[i]); + xbt_free(arg->argv); xbt_free(arg->name); xbt_free(arg); } @@ -323,9 +327,10 @@ void SIMIX_host_restart_processes(smx_host_t host) unsigned int cpt; smx_process_arg_t arg; xbt_dynar_t process_list = SIMIX_host_priv(host)->auto_restart_processes; - if(!process_list) return; + if (!process_list) + return; - xbt_dynar_foreach(process_list,cpt,arg) { + xbt_dynar_foreach (process_list, cpt, arg) { smx_process_t process; @@ -341,20 +346,24 @@ void SIMIX_host_restart_processes(smx_host_t host) arg->argv, arg->properties, arg->auto_restart); - } - else { + } else { simcall_process_create(&process, - arg->argv[0], - arg->code, - NULL, - arg->hostname, - arg->kill_time, - arg->argc, - arg->argv, - arg->properties, - arg->auto_restart); + arg->argv[0], + arg->code, + NULL, + arg->hostname, + arg->kill_time, + arg->argc, + arg->argv, + arg->properties, + arg->auto_restart); } + /* arg->argv is used by the process created above. Hide it to + * _SIMIX_host_free_process_arg() which is called by xbt_dynar_reset() + * below. */ + arg->argc = 0; + arg->argv = NULL; } xbt_dynar_reset(process_list); } diff --git a/src/simix/smx_process.c b/src/simix/smx_process.c index e3bc046a0e..bc5c0871a0 100644 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.c @@ -122,8 +122,8 @@ void SIMIX_process_empty_trash(void) xbt_dynar_free(&process->on_exit); - free(process->name); - free(process); + xbt_free(process->name); + xbt_free(process); } } @@ -239,8 +239,12 @@ void SIMIX_process_create(smx_process_t *process, XBT_DEBUG("Start process %s on host '%s'", name, hostname); if (!SIMIX_host_get_state(host)) { + int i; XBT_WARN("Cannot launch process '%s' on failed host '%s'", name, hostname); + for (i = 0; i < argc; i++) + xbt_free(argv[i]); + xbt_free(argv); } else { *process = xbt_new0(s_smx_process_t, 1);