X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5736ddf26ccce2afd1eb27b5ee74ff869673cac4..3e33945312989c2b5a84a31efafd429185ece096:/src/xbt/module.c?ds=sidebyside diff --git a/src/xbt/module.c b/src/xbt/module.c index a79815f017..652b0c795a 100644 --- a/src/xbt/module.c +++ b/src/xbt/module.c @@ -9,7 +9,6 @@ #include "xbt/sysdep.h" #include "xbt/log.h" -#include "xbt/error.h" #include "xbt/dynar.h" #include "xbt/config.h" @@ -19,6 +18,9 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(module,xbt, "module handling"); +char *xbt_binary_name=NULL; /* Mandatory to retrieve neat backtraces */ +int xbt_initialized=0; + struct xbt_module_ { xbt_dynar_t *deps; xbt_cfg_t *cfg; @@ -30,11 +32,12 @@ struct xbt_module_ { /** @brief Initialize the xbt mechanisms. */ void xbt_init(int *argc, char **argv) { - static short int first_run = 1; - if (!first_run) + xbt_initialized++; + + if (xbt_initialized!=1) return; - - first_run = 0; + + xbt_binary_name = strdup(argv[0]); VERB0("Initialize XBT"); xbt_log_init(argc,argv); @@ -43,6 +46,9 @@ xbt_init(int *argc, char **argv) { /** @brief Finalize the xbt mechanisms. */ void xbt_exit(){ + xbt_initialized--; + if (xbt_initialized == 0) + free(xbt_binary_name); xbt_log_exit(); }