X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/763ea0fa6120d18f99e2e5e8164a4cf5821c547c..d6a677eea07bbb917ebf8aef3d281f37049c5254:/src/xbt/xbt_os_thread.c diff --git a/src/xbt/xbt_os_thread.c b/src/xbt/xbt_os_thread.c index 7bd87a6ac7..af1dc12778 100644 --- a/src/xbt/xbt_os_thread.c +++ b/src/xbt/xbt_os_thread.c @@ -92,11 +92,11 @@ void xbt_os_thread_mod_preinit(void) int errcode = pthread_key_create(&xbt_self_thread_key, NULL); xbt_assert(errcode == 0, "pthread_key_create failed for xbt_self_thread_key"); - + main_thread = xbt_new(s_xbt_os_thread_t, 1); main_thread->name = NULL; main_thread->detached = 0; - main_thread->name = (char *) "main"; + main_thread->name = xbt_strdup("main"); main_thread->param = NULL; main_thread->start_routine = NULL; main_thread->extra_data = NULL; @@ -122,6 +122,7 @@ void xbt_os_thread_mod_postexit(void) // if ((errcode=pthread_key_delete(xbt_self_thread_key))) // THROWF(system_error,errcode,"pthread_key_delete failed for xbt_self_thread_key"); + free(main_thread->name); free(main_thread); main_thread = NULL; thread_mod_inited = 0; @@ -164,7 +165,7 @@ xbt_os_thread_t xbt_os_thread_create(const char *name, pvoid_f_pvoid_t start_ro res_thread->start_routine = start_routine; res_thread->param = param; res_thread->extra_data = extra_data; - + int errcode = pthread_create(&(res_thread->t), &thread_attr, wrapper_start_routine, res_thread); xbt_assert(errcode == 0, "pthread_create failed: %s", strerror(errcode)); @@ -234,7 +235,7 @@ void xbt_os_thread_setguardsize(int guard_size) const char *xbt_os_thread_self_name(void) { xbt_os_thread_t me = xbt_os_thread_self(); - return me ? me->name : "main"; + return me ? (const char *)me->name : "main"; } void xbt_os_thread_join(xbt_os_thread_t thread, void **thread_return)