From: mquinson Date: Tue, 20 Jun 2006 23:09:56 +0000 (+0000) Subject: Proper module use count to plug a (tiny) memleak X-Git-Tag: v3.3~2947 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/75ab9579163d7854f8a262ab0cc04739d876b538?hp=c7b2c29e2b9a749e6d4d2c6bf34c1e2501c274e1;ds=sidebyside Proper module use count to plug a (tiny) memleak git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2411 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/xbt/module.c b/src/xbt/module.c index 69b1db4c5e..652b0c795a 100644 --- a/src/xbt/module.c +++ b/src/xbt/module.c @@ -19,6 +19,7 @@ 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; @@ -31,12 +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; xbt_binary_name = strdup(argv[0]); - first_run = 0; VERB0("Initialize XBT"); xbt_log_init(argc,argv); @@ -45,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(); }